diff --git a/test/yarp/fuzzer_test.rb b/test/yarp/fuzzer_test.rb index 52d7f77e9f..2d851ff886 100644 --- a/test/yarp/fuzzer_test.rb +++ b/test/yarp/fuzzer_test.rb @@ -22,4 +22,5 @@ class FuzzerTest < Test::Unit::TestCase snippet "incomplete octal number", "0o" snippet "incomplete hex number", "0x" snippet "incomplete escaped list", "%w[\\" + snippet "incomplete escaped regex", "/a\\" end diff --git a/yarp/yarp.c b/yarp/yarp.c index 3b2f29bf01..3fa143f31e 100644 --- a/yarp/yarp.c +++ b/yarp/yarp.c @@ -7091,6 +7091,12 @@ parser_lex(yp_parser_t *parser) { // literally. In this case we'll skip past the next character // and find the next breakpoint. if (*breakpoint == '\\') { + // Check that we're not at the end of the file. + if (breakpoint + 1 >= parser->end) { + breakpoint = NULL; + continue; + } + size_t difference = yp_unescape_calculate_difference(parser, breakpoint, YP_UNESCAPE_ALL, false); // If the result is an escaped newline ...