summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Dalessio <mike.dalessio@gmail.com>2023-08-29 15:12:06 -0400
committergit <svn-admin@ruby-lang.org>2023-08-30 18:27:48 +0000
commit476f38d62dd24caf80c586b642a25ede66b13fab (patch)
tree93ae7c9b3075ab03aae6f96cac2c896a0f8cdd7f
parent3da139d28428d9889f6b6680400242f400e3175e (diff)
[ruby/yarp] fix: ":" at the end of a file
Previously this resulted in invalid memory access. Found by the fuzzer. https://github.com/ruby/yarp/commit/c781c9fcd2
-rw-r--r--test/yarp/fuzzer_test.rb1
-rw-r--r--yarp/yarp.c2
2 files changed, 2 insertions, 1 deletions
diff --git a/test/yarp/fuzzer_test.rb b/test/yarp/fuzzer_test.rb
index dd8a25864c..6962e6be76 100644
--- a/test/yarp/fuzzer_test.rb
+++ b/test/yarp/fuzzer_test.rb
@@ -13,4 +13,5 @@ class FuzzerTest < Test::Unit::TestCase
end
snippet "incomplete global variable", "$"
+ snippet "incomplete symbol", ":"
end
diff --git a/yarp/yarp.c b/yarp/yarp.c
index 4b8ff07a98..15511ebc9e 100644
--- a/yarp/yarp.c
+++ b/yarp/yarp.c
@@ -6581,7 +6581,7 @@ parser_lex(yp_parser_t *parser) {
LEX(YP_TOKEN_COLON_COLON);
}
- if (lex_state_end_p(parser) || yp_char_is_whitespace(*parser->current.end) || peek(parser) == '#') {
+ if (lex_state_end_p(parser) || yp_char_is_whitespace(peek(parser)) || peek(parser) == '#') {
lex_state_set(parser, YP_LEX_STATE_BEG);
LEX(YP_TOKEN_COLON);
}