fix bug when heredoc_identifier length exceeds CHAR_MAX

This commit is contained in:
mhoffm
2021-06-27 22:27:21 +02:00
parent 122818e4df
commit 29bb003f95
3 changed files with 26 additions and 0 deletions

View File

@@ -6,6 +6,8 @@
#include <wctype.h>
#include <assert.h>
#include <stdio.h>
namespace {
using std::vector;
@@ -49,6 +51,9 @@ public:
if (size + 2 + it->heredoc_identifier.size() >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) {
return 0;
}
if (it->heredoc_identifier.size() > CHAR_MAX) {
return 0;
}
buf[size++] = it->type;
buf[size++] = it->heredoc_identifier.size();
it->heredoc_identifier.copy(&buf[size], it->heredoc_identifier.size());