bignum.c: rb_int_parse_cstr handle 0 strings

[Bug #19390]

We shouldn't check the string length when skipping zeros, as the
string might only contains zero characters, resulting in an empty string.
This commit is contained in:
Jean Boussier 2023-01-30 11:03:50 +01:00 committed by Jean Boussier
parent 4bc343b436
commit 3f54d09a5b
Notes: git 2023-01-30 13:43:05 +00:00
2 changed files with 4 additions and 1 deletions

View File

@ -4184,7 +4184,6 @@ rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits,
} }
if (!c || ISSPACE(c)) --str; if (!c || ISSPACE(c)) --str;
if (end) len = end - str; if (end) len = end - str;
ASSERT_LEN();
} }
c = *str; c = *str;
c = conv_digit(c); c = conv_digit(c);

View File

@ -1426,4 +1426,8 @@ class TestTime < Test::Unit::TestCase
t.deconstruct_keys(%i[year month sec nonexistent]) t.deconstruct_keys(%i[year month sec nonexistent])
) )
end end
def test_parse_zero_bigint
assert_equal 0, Time.new("2020-10-28T16:48:07.000Z").nsec, '[Bug #19390]'
end
end end