diff options
author | Mike Dalessio <mike.dalessio@gmail.com> | 2023-08-29 23:03:16 -0400 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-08-30 18:27:51 +0000 |
commit | 7cebb9b737eddced828073453004720f9970be6a (patch) | |
tree | e2619599d91cf86fafba6129a94a5b0f6da93292 /yarp/yarp.c | |
parent | 46e47404a8734efd7f312e29e2fb705dd2f40291 (diff) |
[ruby/yarp] fix: incomplete escape in list at the end of file
Previously this resulted in invalid memory access.
Found by the fuzzer.
https://github.com/ruby/yarp/commit/78ed75ed75
Diffstat (limited to 'yarp/yarp.c')
-rw-r--r-- | yarp/yarp.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/yarp/yarp.c b/yarp/yarp.c index 6b2a3c64e8..3b2f29bf01 100644 --- a/yarp/yarp.c +++ b/yarp/yarp.c @@ -6952,6 +6952,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; + } + yp_unescape_type_t unescape_type = lex_mode->as.list.interpolation ? YP_UNESCAPE_ALL : YP_UNESCAPE_MINIMAL; size_t difference = yp_unescape_calculate_difference(parser, breakpoint, unescape_type, false); |