1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:47:45 +00:00

LibJS: Fix start position of multi-line tokens

This broke in case of unterminated regular expressions, causing goofy location
numbers, and 'source_location_hint' to eat up all memory:

Unexpected token UnterminatedRegexLiteral. Expected statement (line: 2, column: 4294967292)
This commit is contained in:
Ben Wiederhake 2020-08-29 19:40:28 +02:00 committed by Andreas Kling
parent 0d3a8d5397
commit 5d3c437cce
2 changed files with 23 additions and 15 deletions

View file

@ -36,7 +36,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
auto lexer = JS::Lexer(js);
auto parser = JS::Parser(lexer);
parser.parse_program();
if (parser.has_errors())
parser.print_errors();
if (parser.has_errors()) {
for (auto& error : parser.errors()) {
if (error.line >= 100000 || error.column >= 100000) {
fprintf(stderr, "%s\n", error.to_string().characters());
ASSERT_NOT_REACHED();
}
}
}
return 0;
}