diff options
author | Mike Dalessio <[email protected]> | 2023-11-12 13:47:11 -0500 |
---|---|---|
committer | git <[email protected]> | 2023-11-14 05:25:46 +0000 |
commit | e020eb26f060d96e332a1beb1001716ddda7a7a6 (patch) | |
tree | 03df402ec12bea4fb8f7d1bafd9b3be7b3ecf2ac | |
parent | 33b92c2d6bcba16382cbb33159b8ce7e4d9802de (diff) |
[ruby/prism] fix: Handle zero-length block parameters in invalid Ruby
Found by fuzzing.
https://github.com/ruby/prism/commit/4cd6c8cf98
-rw-r--r-- | prism/prism.c | 2 | ||||
-rw-r--r-- | test/prism/fuzzer_test.rb | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/prism/prism.c b/prism/prism.c index 4bac4d8c76..312036770b 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -5610,7 +5610,7 @@ pm_parser_parameter_name_check(pm_parser_t *parser, const pm_token_t *name) { } // We want to ignore any parameter name that starts with an underscore. - if ((*name->start == '_')) return; + if ((name->start < name->end) && (*name->start == '_')) return; // Otherwise we'll fetch the constant id for the parameter name and check // whether it's already in the current scope. diff --git a/test/prism/fuzzer_test.rb b/test/prism/fuzzer_test.rb index 04e45518b1..0aabd56242 100644 --- a/test/prism/fuzzer_test.rb +++ b/test/prism/fuzzer_test.rb @@ -57,5 +57,7 @@ module Prism a /{/, ''\\ RUBY + + snippet "parameter name that is zero length", "a { |b;" end end |