diff options
| author | Mike Dalessio <mike.dalessio@gmail.com> | 2023-08-30 14:03:03 -0400 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2023-08-30 18:27:52 +0000 |
| commit | 2d009805e71e76c4f7678409aea804e18df01446 (patch) | |
| tree | edb23fc72e8dfe6a036ddb3de14694fb992e1f4b | |
| parent | ae7f9075592ea3570dfba831d086c423301fbcb7 (diff) | |
[ruby/yarp] fix: comment followed by whitespace at end of file
Previously this resulted in invalid memory access.
Found by the fuzzer.
https://github.com/ruby/yarp/commit/b248553dd6
| -rw-r--r-- | test/yarp/fuzzer_test.rb | 1 | ||||
| -rw-r--r-- | yarp/yarp.c | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/test/yarp/fuzzer_test.rb b/test/yarp/fuzzer_test.rb index 6dfbf94f39..8d818897a6 100644 --- a/test/yarp/fuzzer_test.rb +++ b/test/yarp/fuzzer_test.rb @@ -16,6 +16,7 @@ class FuzzerTest < Test::Unit::TestCase snippet "incomplete symbol", ":" snippet "incomplete escaped string", '"\\' snippet "trailing comment", "1\n#\n" + snippet "comment followed by whitespace at end of file", "1\n#\n " snippet "trailing asterisk", "a *" snippet "incomplete decimal number", "0d" snippet "incomplete binary number", "0b" diff --git a/yarp/yarp.c b/yarp/yarp.c index 37d55cd467..2422fb4571 100644 --- a/yarp/yarp.c +++ b/yarp/yarp.c @@ -5921,7 +5921,7 @@ parser_lex(yp_parser_t *parser) { // If this is not followed by a comment, then we can break out // of this loop. - if (*following != '#') break; + if (peek_at(parser, following) != '#') break; // If there is a comment, then we need to find the end of the // comment and continue searching from there. |
