diff --git a/src/scanner.cc b/src/scanner.cc index 15de616..196153e 100644 --- a/src/scanner.cc +++ b/src/scanner.cc @@ -34,13 +34,13 @@ struct Scanner { Tag &tag = tags[j]; if (tag.type == CUSTOM) { 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(tag.type); buffer[i++] = name_length; tag.custom_tag_name.copy(&buffer[i], name_length); i += name_length; } else { - if (i + 1 > TREE_SITTER_SERIALIZATION_BUFFER_SIZE) break; + if (i + 1 >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) break; buffer[i++] = static_cast(tag.type); } }