]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: fix bignum_to_fixnum_strict for BIGNUM_ZERO.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 8 Jun 2014 23:05:36 +0000 (16:05 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 8 Jun 2014 23:05:36 +0000 (16:05 -0700)
vm/bignum.cpp

index 799099e3c6df7bf7380f379c44eb6836c8ca4aef..0880de1f94eec69a4ee73b1a1ba2f13c3bbcca12 100644 (file)
@@ -385,6 +385,8 @@ BIGNUM_TO_FOO(ulong_long, uint64_t, int64_t, uint64_t)
 
 /* cannot allocate memory */
 fixnum factor_vm::bignum_to_fixnum_strict(bignum* bignum_in) {
+  if (BIGNUM_ZERO_P(bignum_in))
+    return 0;
   fixnum len = BIGNUM_LENGTH(bignum_in);
   bignum_digit_type *digits = BIGNUM_START_PTR(bignum_in);
   if ((len == 1 && digits[0] > fixnum_max) || (len > 1)) {