Skip to content

Fix linked list iteration when displaying errors #13936

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

Merged
merged 1 commit into from
Jul 17, 2025

Conversation

tenderlove
Copy link
Member

When a script has problem with the magic comment encoding, we only display that error. However, if there are other syntax errors in the file, the error linked list could contain multiple items. This lead to an inconsistency in the "size" field of the linked list, and the actual items in the linked list. In other words, the linked list had more than one item, but the size field was one.

The error display routine would only allocate size items, but iterating the linked list would overrun the array. This commit changes the iterator to compare the current node to the "finish" node in the linked list, no longer assuming the linked list ends with NULL.

[Bug #21461]

When a script has problem with the magic comment encoding, we only
display that error.  However, if there are other syntax errors in the
file, the error linked list could contain multiple items.  This lead to
an inconsistency in the "size" field of the linked list, and the actual
items in the linked list.  In other words, the linked list had more than
one item, but the size field was one.

The error display routine would only allocate `size` items, but
iterating the linked list would overrun the array.  This commit changes
the iterator to compare the current node to the "finish" node in the
linked list, no longer assuming the linked list ends with NULL.

[Bug #21461]
@tenderlove tenderlove enabled auto-merge (rebase) July 17, 2025 18:22
@tenderlove tenderlove merged commit dabdd81 into ruby:master Jul 17, 2025
81 of 84 checks passed
@tenderlove tenderlove deleted the fix-asan-error branch July 17, 2025 23:53
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