Fix dtoa buffer overrun
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fa7f75ddda
commit
69f9992ed4
@ -171,6 +171,24 @@ class TestFloat < Test::Unit::TestCase
|
|||||||
assert_raise(ArgumentError, n += z + "A") {Float(n)}
|
assert_raise(ArgumentError, n += z + "A") {Float(n)}
|
||||||
assert_raise(ArgumentError, n += z + ".0") {Float(n)}
|
assert_raise(ArgumentError, n += z + ".0") {Float(n)}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
x = nil
|
||||||
|
2000.times do
|
||||||
|
x = Float("0x"+"0"*30)
|
||||||
|
break unless x == 0.0
|
||||||
|
end
|
||||||
|
assert_equal(0.0, x, ->{"%a" % x})
|
||||||
|
x = nil
|
||||||
|
2000.times do
|
||||||
|
begin
|
||||||
|
x = Float("0x1."+"0"*270)
|
||||||
|
rescue ArgumentError => e
|
||||||
|
raise unless /"0x1\.0{270}"/ =~ e.message
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert_nil(x, ->{"%a" % x})
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_divmod
|
def test_divmod
|
||||||
|
3
util.c
3
util.c
@ -2081,6 +2081,7 @@ break2:
|
|||||||
if (!*++s || !(s1 = strchr(hexdigit, *s))) goto ret0;
|
if (!*++s || !(s1 = strchr(hexdigit, *s))) goto ret0;
|
||||||
if (*s == '0') {
|
if (*s == '0') {
|
||||||
while (*++s == '0');
|
while (*++s == '0');
|
||||||
|
if (!*s) goto ret;
|
||||||
s1 = strchr(hexdigit, *s);
|
s1 = strchr(hexdigit, *s);
|
||||||
}
|
}
|
||||||
if (s1 != NULL) {
|
if (s1 != NULL) {
|
||||||
@ -2103,7 +2104,7 @@ break2:
|
|||||||
for (; *s && (s1 = strchr(hexdigit, *s)); ++s) {
|
for (; *s && (s1 = strchr(hexdigit, *s)); ++s) {
|
||||||
adj += aadj * ((s1 - hexdigit) & 15);
|
adj += aadj * ((s1 - hexdigit) & 15);
|
||||||
if ((aadj /= 16) == 0.0) {
|
if ((aadj /= 16) == 0.0) {
|
||||||
while (strchr(hexdigit, *++s));
|
while (*++s && strchr(hexdigit, *s));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#define RUBY_VERSION "2.6.10"
|
#define RUBY_VERSION "2.6.10"
|
||||||
#define RUBY_RELEASE_DATE "2022-04-12"
|
#define RUBY_RELEASE_DATE "2022-04-12"
|
||||||
#define RUBY_PATCHLEVEL 209
|
#define RUBY_PATCHLEVEL 210
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2022
|
#define RUBY_RELEASE_YEAR 2022
|
||||||
#define RUBY_RELEASE_MONTH 4
|
#define RUBY_RELEASE_MONTH 4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user