Skip to content

Conversation

@olawlor
Copy link

@olawlor olawlor commented Oct 2, 2024

If target isn't in the list, find_indirect will walk off the end and dereference NULL.

Example:

list_item item1 = { 3, NULL };
list_item item0 = { 1, &item1 };
list L = {&item0};

list_item itemZ = { 0, NULL };

list_item **it = find_indirect(&L,&itemZ);

Currently both the README and code comments claim this should return a pointer to item1.next, which isn't the case.

This pull clarifies the code comments to reflect the code's actual behavior, and adds a parenthetical in the README about how you could detect and handle the not found case in find_indirect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant