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

Resolving a crash when freeing a null pointer when cancelling parses #1938

Merged

Conversation

logancollins
Copy link
Contributor

This pull request resolves a potential crash we've seen in parser.c.

If a parse is in progress, in certain cases, the lookahead.ptr pointer can be NULL when the code reaches src/parser.c#L. This will only actually crash if the cancellation token happens to have been set to a non-zero value.

This request contains a check to ensure that lookahead.ptr is not NULL before releasing the subtree.

I'm not entirely up on all of the potential branch cases and other code with which this might interact, so I'm happy for a review to ensure this is an acceptable fix!

Thank you!

@maxbrunsfeld maxbrunsfeld merged commit 757c032 into tree-sitter:master Oct 31, 2022
@maxbrunsfeld
Copy link
Contributor

Thanks for the fix @logancollins; this makes a lot of sense.

@Aman-preetam

This comment was marked as spam.

@Aman-preetam

This comment was marked as spam.

@logancollins logancollins deleted the merge/parse-cancel-pointer-crash branch March 20, 2024 20:10
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.

None yet

3 participants