diff options
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1257,8 +1257,14 @@ rb_big2ull(VALUE x) { unsigned LONG_LONG num = big2ull(x, "unsigned long long"); - if (!RBIGNUM_SIGN(x)) - return (VALUE)(-(SIGNED_VALUE)num); + if (!RBIGNUM_SIGN(x)) { + VALUE v = (VALUE)(-(SIGNED_VALUE)num); + + /* FIXNUM_MIN-1 .. LLONG_MIN mapped into 0xbfffffffffffffff .. LONG_MAX+1 */ + if (v <= LLONG_MAX) + rb_raise(rb_eRangeError, "bignum out of range of unsigned long long"); + return v; + } return num; } |