Skip to content

Commit 78efd96

Browse files
committed
Crash earlier if native external scanner overflows serialization buffer
1 parent e9fd4cc commit 78efd96

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/src/parser.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,12 @@ static unsigned ts_parser__external_scanner_serialize(
397397
self->lexer.debug_buffer
398398
);
399399
} else {
400-
return self->language->external_scanner.serialize(
400+
uint32_t length = self->language->external_scanner.serialize(
401401
self->external_scanner_payload,
402402
self->lexer.debug_buffer
403403
);
404+
assert(length <= TREE_SITTER_SERIALIZATION_BUFFER_SIZE);
405+
return length;
404406
}
405407
}
406408

0 commit comments

Comments
 (0)