Skip to content

Commit 1c353f6

Browse files
Avoid OOB index in tree-sitter query parser/builder
This works around a bug in tree-sitter where the query parser/builder accesses an array out-of-bounds causing undefined behavior. This fixes a non-deterministic bug that would affect the behavior of the comment grammar in Rust injections - sometimes comment tokens like WARN would not be highlighted. Note that this change to the query is cosmetic: the position of predicates in a pattern is not consequential. The bug upstream is tracked in <https://redirect.github.com/tree-sitter/tree-sitter/issues/4421>. Co-authored-by: Pascal Kuthe <[email protected]>
1 parent c3c26d7 commit 1c353f6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

runtime/queries/rust/injections.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
(call_expression
6262
function: (scoped_identifier
63-
path: (scoped_identifier (identifier) @_regex (#any-of? @_regex "Regex" "RegexBuilder") .)
63+
path: (scoped_identifier (identifier) @_regex . (#any-of? @_regex "Regex" "RegexBuilder"))
6464
name: (identifier) @_new (#eq? @_new "new"))
6565
arguments: (arguments (raw_string_literal (string_content) @injection.content))
6666
(#set! injection.language "regex"))

0 commit comments

Comments
 (0)