Skip to content

fix(rust): prevent overflow in error message calculation#4632

Merged
clason merged 1 commit intotree-sitter:masterfrom
ribru17:rust_bindings_bounds_fix
Jul 22, 2025
Merged

fix(rust): prevent overflow in error message calculation#4632
clason merged 1 commit intotree-sitter:masterfrom
ribru17:rust_bindings_bounds_fix

Conversation

@ribru17
Copy link
Contributor

@ribru17 ribru17 commented Jul 22, 2025

Problem: When encountering an invalid symbol at the beginning of the file, the rust bindings attempt to index the character at position -1 of the query source, which leads to an overflow and thus invalid character index which causes a panic.

Solution: Bounds check the offset before performing the subtraction.

**Problem:** When encountering an invalid symbol at the beginning of the
file, the rust bindings attempt to index the character at position -1 of
the query source, which leads to an overflow and thus invalid character
index which causes a panic.

**Solution:** Bounds check the offset before performing the subtraction.
@clason clason merged commit dff828c into tree-sitter:master Jul 22, 2025
20 checks passed
@tree-sitter-ci-bot
Copy link

Successfully created backport PR for release-0.25:

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants