summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNARUSE, Yui <naruse@airemix.jp>2023-01-31 13:39:13 +0900
committerNARUSE, Yui <naruse@airemix.jp>2023-01-31 13:39:13 +0900
commit5a2b28909ece2e1310250180f097bfcb7b0203dc (patch)
tree66ec658dd43b073fa6195a417937299821ab0caf
parent1689d8bb4843f92c1805e4a4bdd94049569198f4 (diff)
downloadruby-5a2b28909ece2e1310250180f097bfcb7b0203dc.tar.gz
merge revision(s) 3f54d09a5b8b6e4fd734abc8911e170d5967b5b0: [Backport #19390]
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. --- bignum.c | 1 - test/ruby/test_time.rb | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-)
-rw-r--r--bignum.c1
-rw-r--r--test/ruby/test_time.rb4
-rw-r--r--version.h2
3 files changed, 5 insertions, 2 deletions
diff --git a/bignum.c b/bignum.c
index 4f8349dd17..8ef19e9751 100644
--- a/bignum.c
+++ b/bignum.c
@@ -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 (end) len = end - str;
- ASSERT_LEN();
}
c = *str;
c = conv_digit(c);
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index 38c1af6901..2bf6056a49 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -1426,4 +1426,8 @@ class TestTime < Test::Unit::TestCase
t.deconstruct_keys(%i[year month sec nonexistent])
)
end
+
+ def test_parse_zero_bigint
+ assert_equal 0, Time.new("2020-10-28T16:48:07.000Z").nsec, '[Bug #19390]'
+ end
end
diff --git a/version.h b/version.h
index 13b490f2c4..a26c469164 100644
--- a/version.h
+++ b/version.h
@@ -11,7 +11,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 22
+#define RUBY_PATCHLEVEL 23
#include "ruby/version.h"
#include "ruby/internal/abi.h"