Avoid integer truncation when serializing tag lengths
A tag longer than 255 characters will be incorrectly serialized. Co-authored-by: Rahul Zhade <zhade3@github.com>
This commit is contained in:
parent
3e586b10fc
commit
2eda6161d6
|
@ -34,6 +34,7 @@ struct Scanner {
|
|||
Tag &tag = tags[j];
|
||||
if (tag.type == CUSTOM) {
|
||||
unsigned name_length = tag.custom_tag_name.size();
|
||||
if (name_length > UINT8_MAX) break;
|
||||
if (i + 2 + name_length >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) break;
|
||||
buffer[i++] = static_cast<char>(tag.type);
|
||||
buffer[i++] = name_length;
|
||||
|
|
Loading…
Reference in New Issue