1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2007-07-18 07:57:45 +00:00
parent 233221db60
commit ec6e26742c
2 changed files with 7 additions and 1 deletions

View file

@ -1,3 +1,7 @@
Wed Jul 18 16:57:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bignum.c (rb_big_pow): refine overflow check. [ruby-dev:31242]
Wed Jul 18 09:19:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (rb_parser_append_print, rb_parser_while_loop): moved check

View file

@ -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;