Skip to content

Commit 694d636

Browse files
committed
fix(lib): correct fix for parsing hang with ranges containing empty points
It's more correct to check the bytes of the `size` length, rather than use the point as a condition for resetting the lexer's token start position
1 parent f3d50f2 commit 694d636

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/src/lexer.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,7 @@ void ts_lexer_finish(Lexer *self, uint32_t *lookahead_end_byte) {
424424
// If the token ended at an included range boundary, then its end position
425425
// will have been reset to the end of the preceding range. Reset the start
426426
// position to match.
427-
if (
428-
self->token_end_position.bytes < self->token_start_position.bytes ||
429-
point_lt(self->token_end_position.extent, self->token_start_position.extent)
430-
) {
427+
if (self->token_end_position.bytes < self->token_start_position.bytes) {
431428
self->token_start_position = self->token_end_position;
432429
}
433430

lib/src/subtree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ static inline bool ts_subtree_can_inline(Length padding, Length size, uint32_t l
157157
padding.bytes < TS_MAX_INLINE_TREE_LENGTH &&
158158
padding.extent.row < 16 &&
159159
padding.extent.column < TS_MAX_INLINE_TREE_LENGTH &&
160+
size.bytes < TS_MAX_INLINE_TREE_LENGTH &&
160161
size.extent.row == 0 &&
161162
size.extent.column < TS_MAX_INLINE_TREE_LENGTH &&
162163
lookahead_bytes < 16;

0 commit comments

Comments
 (0)