Added a sanity check for input size.

This commit is contained in:
Mike Lischke 2021-03-10 11:49:22 +01:00
parent 84d4ce73de
commit 5731e64e22
1 changed files with 2 additions and 2 deletions

View File

@ -45,8 +45,8 @@ void ANTLRInputStream::load(const std::string &input) {
void ANTLRInputStream::load(const char *data, size_t length) {
// Remove the UTF-8 BOM if present.
const char bom[4] = "\xef\xbb\xbf";
if (strncmp(data, bom, 3) == 0)
const char *bom = "\xef\xbb\xbf";
if (length > 3 && strncmp(data, bom, 3) == 0)
_data = antlrcpp::utf8_to_utf32(data + 3, data + length);
else
_data = antlrcpp::utf8_to_utf32(data, data + length);