Fix off-by-one error in scanner buffer size limit
This commit is contained in:
parent
e74795bc0d
commit
083e6b9fbd
|
@ -34,13 +34,13 @@ struct Scanner {
|
||||||
Tag &tag = tags[j];
|
Tag &tag = tags[j];
|
||||||
if (tag.type == CUSTOM) {
|
if (tag.type == CUSTOM) {
|
||||||
unsigned name_length = tag.custom_tag_name.size();
|
unsigned name_length = tag.custom_tag_name.size();
|
||||||
if (i + 2 + name_length > TREE_SITTER_SERIALIZATION_BUFFER_SIZE) break;
|
if (i + 2 + name_length >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) break;
|
||||||
buffer[i++] = static_cast<char>(tag.type);
|
buffer[i++] = static_cast<char>(tag.type);
|
||||||
buffer[i++] = name_length;
|
buffer[i++] = name_length;
|
||||||
tag.custom_tag_name.copy(&buffer[i], name_length);
|
tag.custom_tag_name.copy(&buffer[i], name_length);
|
||||||
i += name_length;
|
i += name_length;
|
||||||
} else {
|
} else {
|
||||||
if (i + 1 > TREE_SITTER_SERIALIZATION_BUFFER_SIZE) break;
|
if (i + 1 >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) break;
|
||||||
buffer[i++] = static_cast<char>(tag.type);
|
buffer[i++] = static_cast<char>(tag.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue