fix(lib): fix segfault on ts_query_new with incompatible grammar version, close #1318
This commit is contained in:
parent
0e26fbe5e6
commit
52e6c900c3
5 changed files with 72 additions and 38 deletions
|
|
@ -2069,6 +2069,15 @@ TSQuery *ts_query_new(
|
|||
uint32_t *error_offset,
|
||||
TSQueryError *error_type
|
||||
) {
|
||||
if (
|
||||
!language ||
|
||||
language->version > TREE_SITTER_LANGUAGE_VERSION ||
|
||||
language->version < TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION
|
||||
) {
|
||||
*error_type = TSQueryErrorLanguage;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TSQuery *self = ts_malloc(sizeof(TSQuery));
|
||||
*self = (TSQuery) {
|
||||
.steps = array_new(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue