mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 14:34:39 +02:00
[ruby/yarp] fix: string escape char "\" at the end of a file
Previously this resulted in invalid memory access.
Found by the fuzzer.
178862e2ca
This commit is contained in:
parent
476f38d62d
commit
6f8126faeb
2 changed files with 7 additions and 0 deletions
|
@ -14,4 +14,5 @@ class FuzzerTest < Test::Unit::TestCase
|
|||
|
||||
snippet "incomplete global variable", "$"
|
||||
snippet "incomplete symbol", ":"
|
||||
snippet "incomplete escaped string", '"\\'
|
||||
end
|
||||
|
|
|
@ -7224,6 +7224,12 @@ parser_lex(yp_parser_t *parser) {
|
|||
breakpoint = yp_strpbrk(parser, breakpoint + 1, breakpoints, parser->end - (breakpoint + 1));
|
||||
break;
|
||||
case '\\': {
|
||||
// Check that we're not at the end of the file.
|
||||
if (breakpoint + 1 >= parser->end) {
|
||||
breakpoint = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
// If we hit escapes, then we need to treat the next token
|
||||
// literally. In this case we'll skip past the next character and
|
||||
// find the next breakpoint.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue