You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Rishabh Patel (JIRA)" <ji...@apache.org> on 2015/06/24 21:07:04 UTC

[jira] [Created] (LUCENE-6602) Null value dereference

Rishabh Patel created LUCENE-6602:
-------------------------------------

             Summary: Null value dereference
                 Key: LUCENE-6602
                 URL: https://issues.apache.org/jira/browse/LUCENE-6602
             Project: Lucene - Core
          Issue Type: Bug
          Components: modules/queryparser
    Affects Versions: Trunk
            Reporter: Rishabh Patel
            Priority: Minor


In the file BoostQueryNode.java, getChild could be null and it is being dereferenced in the function toString().

{code:title=BoostQueryNode.java|borderStyle=solid}
  public QueryNode getChild() {
    List<QueryNode> children = getChildren();

    if (children == null || children.size() == 0) {
      return null;
    }

    return children.get(0);

  }{code}

{code:title=BoostQueryNode.java|borderStyle=solid}
public String toString() {
    return "<boost value='" + getValueString() + "'>" + "\n"
        + getChild().toString() + "\n</boost>";
  }
{code}

Should we not check if getChild is valid?
{code:title=Probable fix | borderStyle=solid}
String s = (getChild() != null) ? getChild().toString() : "null";
return "<boost value='" + getValueString() + "'>" + "\n"
        + s + "\n</boost>";
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org