[ 
https://issues.apache.org/jira/browse/LUCENE-6602?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rishabh Patel updated LUCENE-6602:
----------------------------------
    Description: 
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}

  was:
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}


> 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
>              Labels: github-pullrequest
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to