Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify undefined behavior if target isn't in the list #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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