summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/bignum.c b/bignum.c
index 6882580..7c3e029 100644
--- a/bignum.c
+++ b/bignum.c
@@ -729,7 +729,12 @@ rb_big2ulong(x)
{
unsigned long num = big2ulong(x, "unsigned long");
- if (!RBIGNUM(x)->sign) return -num;
+ if (!RBIGNUM(x)->sign) {
+ if ((long)num < 0) {
+ rb_raise(rb_eRangeError, "bignum out of range of unsigned long");
+ }
+ return -num;
+ }
return num;
}