NullPointerException in TIntLinkedList

Issue #41 resolved
Руслан created an issue

Hello. I've found unpleasant bug in method 'indexOf(int, int) in 'TIntLinkedList': there are no any check for empty list, so NPE is raising. Looking to the code of 'TIntLinkedList':

public int indexOf(int offset, int value) {
        int count = offset;
        //if size() == 0, then 'l' becomes null. Calling l.getNext() will raise NPE.
        for (TIntLink l = getLinkAt(offset); got(l.getNext()); l = l.getNext()) {
            if (l.getValue() == value)
                return count;

            count++;
        }

        return -1;
    }

Comments (3)

  1. Log in to comment