Merge pull request #715 from bfredl/ubsan-warnings
Fix a few cases of Clang 10 with UBSAN detecting undefined behavior
This commit is contained in:
commit
55030afd13
2 changed files with 4 additions and 1 deletions
|
|
@ -73,7 +73,6 @@ static void ts_lexer__get_chunk(Lexer *self) {
|
|||
// code that spans the current position.
|
||||
static void ts_lexer__get_lookahead(Lexer *self) {
|
||||
uint32_t position_in_chunk = self->current_position.bytes - self->chunk_start;
|
||||
const uint8_t *chunk = (const uint8_t *)self->chunk + position_in_chunk;
|
||||
uint32_t size = self->chunk_size - position_in_chunk;
|
||||
|
||||
if (size == 0) {
|
||||
|
|
@ -82,6 +81,7 @@ static void ts_lexer__get_lookahead(Lexer *self) {
|
|||
return;
|
||||
}
|
||||
|
||||
const uint8_t *chunk = (const uint8_t *)self->chunk + position_in_chunk;
|
||||
UnicodeDecodeFunction decode = self->input.encoding == TSInputEncodingUTF8
|
||||
? ts_decode_utf8
|
||||
: ts_decode_utf16;
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue