Merge pull request #2177 from tree-sitter/fix-oob-2162

lib: fix OOB in query engine reported in #2162 🐛
This commit is contained in:
Andrew Hlynskyi 2023-04-06 04:28:28 +03:00 committed by GitHub
commit 487e3d0f56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -938,6 +938,9 @@ static inline int analysis_state__compare(
}
static inline AnalysisStateEntry *analysis_state__top(AnalysisState *self) {
if (self->depth == 0) {
return &self->stack[0];
}
return &self->stack[self->depth - 1];
}