diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-07-18 07:57:45 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-07-18 07:57:45 +0000 |
commit | ec6e26742cd467b210c8d2935edb1a0dcb26e0dd (patch) | |
tree | 35d582eebab3963033b6e2698feab1aa7c124269 /bignum.c | |
parent | 233221db60c32a626b7e7d06dae71a4c3f78d380 (diff) | |
download | ruby-ec6e26742cd467b210c8d2935edb1a0dcb26e0dd.tar.gz |
* bignum.c (rb_big_pow): refine overflow check. [ruby-dev:31242]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -1675,8 +1675,10 @@ rb_big_pow(VALUE x, VALUE y) if (yy > 0) { VALUE z = 0; SIGNED_VALUE mask; + const long BIGLEN_LIMIT = 1024*1024 / SIZEOF_BDIGITS; - if (RBIGNUM(x)->len * SIZEOF_BDIGITS * yy > 1024*1024) { + if ((RBIGNUM(x)->len > BIGLEN_LIMIT) || + (RBIGNUM(x)->len > BIGLEN_LIMIT / yy)) { rb_warn("in a**b, b may be too big"); d = (double)yy; break; |