You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "Vladimir Koshelev (JIRA)" <ji...@apache.org> on 2016/03/29 17:34:25 UTC

[jira] [Updated] (LUCENENET-558) Some possible null reference exceptions in ListExtensions.cs

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

Vladimir Koshelev updated LUCENENET-558:
----------------------------------------
    Description: 
https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.Core/Support/ListExtensions.cs#L18

"lt.Add(item);" should be changed to "list.Add(item)"
----------------------------------------------------------------------
https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.Core/Support/ListExtensions.cs#L82

"if (current == null && item == null)" 

The condition means that the list can have null elements.

However, at https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.Core/Support/ListExtensions.cs#L85

"if (current.Equals(item))"

current.Equals() is invoked, thus if the list have a null element, null reference exception would be thrown here.

I suggest to change the condition to (current != null && current.Equals(item)).




  was:
https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.Core/Support/ListExtensions.cs#L18

"lt.Add(item);" should be changed to "list.Add(item)"
----------------------------------------------------------------------
https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.Core/Support/ListExtensions.cs#L82

"if (current == null && item == null)" 

The condition means that list can have null elements.

However, at https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.Core/Support/ListExtensions.cs#L85

"if (current.Equals(item))"

current.Equals() is invoked, thus if the list have a null element, null reference exception would be thrown here.

I suggest to change the condition to (current != null && current.Equals(item)).





> Some possible null reference exceptions in  ListExtensions.cs
> -------------------------------------------------------------
>
>                 Key: LUCENENET-558
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-558
>             Project: Lucene.Net
>          Issue Type: Bug
>          Components: Lucene.Net Core
>            Reporter: Vladimir Koshelev
>             Fix For: Lucene.Net 3.6
>
>
> https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.Core/Support/ListExtensions.cs#L18
> "lt.Add(item);" should be changed to "list.Add(item)"
> ----------------------------------------------------------------------
> https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.Core/Support/ListExtensions.cs#L82
> "if (current == null && item == null)" 
> The condition means that the list can have null elements.
> However, at https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.Core/Support/ListExtensions.cs#L85
> "if (current.Equals(item))"
> current.Equals() is invoked, thus if the list have a null element, null reference exception would be thrown here.
> I suggest to change the condition to (current != null && current.Equals(item)).



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