Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 4fc68b7

Browse files
committed
fix: check for reentrancy in TSParse.parseString
1 parent e67e40a commit 4fc68b7

File tree

1 file changed

+5
-0
lines changed
  • android-tree-sitter/src/main/java/com/itsaky/androidide/treesitter

1 file changed

+5
-0
lines changed

android-tree-sitter/src/main/java/com/itsaky/androidide/treesitter/TSParser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ public TSTree parseString(TSTree oldTree, String source) {
172172
public TSTree parseString(TSTree oldTree, UTF16String source) {
173173
checkAccess();
174174

175+
// Check for reentrancy (same thread calling this method again, before the previous call returned)
176+
if (parseLock.isHeldByCurrentThread()) {
177+
throw new IllegalStateException("Reentrancy detected");
178+
}
179+
175180
// if the parser is currently parsing a syntax tree and the cancellation
176181
// was not requested, throw an error
177182
throwIfParseNotCancelled();

0 commit comments

Comments
 (0)