diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-26 15:34:33 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-26 15:34:33 +0000 |
commit | b9a79bc0202072aeda560d13ff71dae4ea49721c (patch) | |
tree | b5dabdf571901a2c410265883636661848a7754d /bignum.c | |
parent | ab0c37d0cfdeff23a8392c71cbe7e8ea1bc0ac5c (diff) | |
download | ruby-b9a79bc0202072aeda560d13ff71dae4ea49721c.tar.gz |
* io.c (rb_f_backquote): need not to check nil result.
[ruby-core:02078]
* io.c (rb_io_getline): should return nil on eof, even when nil rs is
specified. [ruby-core:02077]
* pack.c (pack_pack): add sign check for 'i', and 'l'.
[ruby-dev:22427]
* bignum.c (rb_quad_pack): add range check for 'quad int'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -203,6 +203,8 @@ rb_quad_pack(buf, val) long len = RBIGNUM(val)->len; BDIGIT *ds; + if (len > SIZEOF_LONG_LONG/SIZEOF_BDIGITS) + rb_raise(rb_eRangeError, "bignum too big to convert into `quad int'"); ds = BDIGITS(val); q = 0; while (len--) { @@ -272,7 +274,9 @@ rb_quad_pack(buf, val) val = rb_int2big(FIX2LONG(val)); } len = RBIGNUM(val)->len * SIZEOF_BDIGITS; - if (len > QUAD_SIZE) len = QUAD_SIZE; + if (len > QUAD_SIZE) { + rb_raise(rb_eRangeError, "bignum too big to convert into `quad int'"); + } memcpy(buf, (char*)BDIGITS(val), len); if (!RBIGNUM(val)->sign) { len = QUAD_SIZE; @@ -759,10 +763,10 @@ long rb_big2long(x) VALUE x; { - unsigned long num = big2ulong(x, "int"); + unsigned long num = big2ulong(x, "long"); if ((long)num < 0 && (RBIGNUM(x)->sign || (long)num != LONG_MIN)) { - rb_raise(rb_eRangeError, "bignum too big to convert into `int'"); + rb_raise(rb_eRangeError, "bignum too big to convert into `long'"); } if (!RBIGNUM(x)->sign) return -(long)num; return num; |