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

Some possible null reference exceptions in ListExtensions.cs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Lucene.Net 4.8.0
    • Lucene.Net 4.8.0
    • Lucene.Net Core
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: