[ruby/yarp] fix: incomplete escape in regex at the end of file
Previously this resulted in invalid memory access. Found by the fuzzer. https://github.com/ruby/yarp/commit/55b9dfb41c
This commit is contained in:
parent
7cebb9b737
commit
341f47a6dd
@ -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
|
||||
|
@ -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 ...
|
||||
|
Loading…
x
Reference in New Issue
Block a user