diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2019-10-21 21:22:53 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2019-10-21 21:24:21 +0900 |
commit | f364564e66d1db1de8e80d669287386595c8bc46 (patch) | |
tree | b02c5be041ae8a1761c021fe9a655ec89d792bed /test | |
parent | c8f97d16202a953a66a326b450a82d926f0fea9c (diff) | |
download | ruby-f364564e66d1db1de8e80d669287386595c8bc46.tar.gz |
bignum.c (estimate_initial_sqrt): prevent integer overflow
`Integer.sqrt(0xffff_ffff_ffff_ffff ** 2)` caused assertion failure
because of integer overflow. [ruby-core:95453] [Bug #16269]
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_integer.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb index 9a4f560ed5..a111698771 100644 --- a/test/ruby/test_integer.rb +++ b/test/ruby/test_integer.rb @@ -640,6 +640,9 @@ class TestInteger < Test::Unit::TestCase failures << n unless root*root <= n && (root+1)*(root+1) > n end assert_empty(failures, bug13440) + + x = 0xffff_ffff_ffff_ffff + assert_equal(x, Integer.sqrt(x ** 2), "[ruby-core:95453]") end def test_fdiv |