Uploaded image for project: 'Lucene.Net'
  1. Lucene.Net
  2. LUCENENET-558

Some possible null reference exceptions in ListExtensions.cs

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Lucene.Net 4.8.0
    • Fix Version/s: Lucene.Net 4.8.0
    • Component/s: Lucene.Net Core
    • Labels:
      None
    • Flags:
      Patch

      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)).

        Attachments

          Activity

            People

            • Assignee:
              nightowl888 Shad Storhaug
              Reporter:
              vedun-z Vladimir Koshelev
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: