Skip to content

Commit

Permalink
Added a sanity check for input size.
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-lischke committed Mar 10, 2021
1 parent 84d4ce7 commit 5731e64
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions runtime/Cpp/runtime/src/ANTLRInputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5731e64

Please sign in to comment.