Fixing overflow checking in certain cases in bignum addition.

(patch from Lorenzo)
This commit is contained in:
Alex Shinn 2012-12-31 10:51:42 +09:00
parent 6a9725996b
commit c0b257db25

View file

@ -344,7 +344,7 @@ sexp sexp_bignum_add_digits (sexp ctx, sexp dst, sexp a, sexp b) {
carry = (n > (SEXP_UINT_T_MAX - bdata[i]) ? 1 : 0); carry = (n > (SEXP_UINT_T_MAX - bdata[i]) ? 1 : 0);
} }
for ( ; carry && (i<alen); i++) { for ( ; carry && (i<alen); i++) {
carry = (cdata[i] == SEXP_UINT_T_MAX-1 ? 1 : 0); carry = (cdata[i] == SEXP_UINT_T_MAX ? 1 : 0);
cdata[i]++; cdata[i]++;
} }
if (carry) { if (carry) {