diff options
author | tompng <[email protected]> | 2025-01-20 21:31:39 +0900 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2025-01-20 14:20:55 +0100 |
commit | 86b262179d94e864243419ac0425cd3f85f970de (patch) | |
tree | bc3f18a27b70f25d3fac6f6cd6f6e015ad1a279d /ext/json/parser/parser.c | |
parent | 525d7a68e4e08aca39ef8ec6af1e78d489cf0bd5 (diff) |
[ruby/json] Reject invalid number: `-` `-.1` `-e0`
https://github.com/ruby/json/commit/b9bfeecfa9
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12602
Diffstat (limited to 'ext/json/parser/parser.c')
-rw-r--r-- | ext/json/parser/parser.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c index 351b7f6fac..9cbe2c1d7e 100644 --- a/ext/json/parser/parser.c +++ b/ext/json/parser/parser.c @@ -990,6 +990,8 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config) raise_parse_error("invalid number: %s", start); } else if (RB_UNLIKELY(integer_length > 2 && start[0] == '-' && start[1] == '0')) { raise_parse_error("invalid number: %s", start); + } else if (RB_UNLIKELY(integer_length == 1 && start[0] == '-')) { + raise_parse_error("invalid number: %s", start); } if ((state->cursor < state->end) && (*state->cursor == '.')) { |