summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Dalessio <mike.dalessio@gmail.com>2023-11-13 18:14:54 -0500
committergit <svn-admin@ruby-lang.org>2023-11-14 14:25:41 +0000
commit26d11383e548dccd7493079daeb9626c059aa87f (patch)
treedff57f57cc26ffcdcd9d635404dbbbedaa97646b
parentd6d1a1839abb64b40e5490509b498757a68c77f1 (diff)
[ruby/prism] fix: float suffix at end of file
Found by fuzzing. https://github.com/ruby/prism/commit/d77d4fe2b7
-rw-r--r--prism/prism.c2
-rw-r--r--test/prism/fuzzer_test.rb1
2 files changed, 2 insertions, 1 deletions
diff --git a/prism/prism.c b/prism/prism.c
index 41dca4cb65..15e550d245 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -6338,7 +6338,7 @@ lex_optional_float_suffix(pm_parser_t *parser, bool* seen_e) {
(void) (match(parser, '+') || match(parser, '-'));
*seen_e = true;
- if (pm_char_is_decimal_digit(*parser->current.end)) {
+ if (pm_char_is_decimal_digit(peek(parser))) {
parser->current.end++;
parser->current.end += pm_strspn_decimal_number_validate(parser, parser->current.end);
type = PM_TOKEN_FLOAT;
diff --git a/test/prism/fuzzer_test.rb b/test/prism/fuzzer_test.rb
index 0aabd56242..ac112f897a 100644
--- a/test/prism/fuzzer_test.rb
+++ b/test/prism/fuzzer_test.rb
@@ -35,6 +35,7 @@ module Prism
snippet "escaped unicode at end of file 7", '"\\u3'
snippet "escaped unicode at end of file 8", '"\\u33'
snippet "escaped unicode at end of file 9", '"\\u333'
+ snippet "float suffix at end of file", "1e"
snippet "statements node with multiple heredocs", <<~EOF
for <<A + <<B