Skip to content

Commit 3f54d09

Browse files
committed
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.
1 parent 4bc343b commit 3f54d09

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

bignum.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4184,7 +4184,6 @@ rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits,
41844184
}
41854185
if (!c || ISSPACE(c)) --str;
41864186
if (end) len = end - str;
4187-
ASSERT_LEN();
41884187
}
41894188
c = *str;
41904189
c = conv_digit(c);

test/ruby/test_time.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,4 +1426,8 @@ def test_deconstruct_keys
14261426
t.deconstruct_keys(%i[year month sec nonexistent])
14271427
)
14281428
end
1429+
1430+
def test_parse_zero_bigint
1431+
assert_equal 0, Time.new("2020-10-28T16:48:07.000Z").nsec, '[Bug #19390]'
1432+
end
14291433
end

0 commit comments

Comments
 (0)