Guard against buffer overflow when serializing scanner

/cc philipturnbull
This commit is contained in:
Max Brunsfeld 2018-01-19 09:52:45 -08:00
parent 700d95cc95
commit 0259c5bce2
1 changed files with 1 additions and 0 deletions

1
src/scanner.cc vendored
View File

@ -28,6 +28,7 @@ struct Scanner {
}
unsigned serialize(char *buffer) {
if (heredoc_delimiter.size() >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) return 0;
heredoc_delimiter.copy(buffer, heredoc_delimiter.length());
return heredoc_delimiter.length();
}