Fix a few cases of Clang 10 with UBSAN detecting undefined behavior

Clang 10 considers adding any offset, including 0, to the null pointer
to be undefined behavior. `(void *)NULL + 0 = kaboom`.
This commit is contained in:
Björn Linse 2020-08-25 19:34:44 +02:00
parent d5576e306c
commit 00c470ab2a
2 changed files with 4 additions and 1 deletions

View file

@ -1252,6 +1252,9 @@ const TSQueryPredicateStep *ts_query_predicates_for_pattern(
) {
Slice slice = self->predicates_by_pattern.contents[pattern_index];
*step_count = slice.length;
if (self->predicate_steps.contents == NULL) {
return NULL;
}
return &self->predicate_steps.contents[slice.offset];
}