From 7d2b60e1aa84a24e14c6e93ea4ecca40ae27c6c1 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Tue, 24 Sep 2013 15:46:23 +0900 Subject: [PATCH] Fixing some bignum length comparisons. --- bignum.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bignum.c b/bignum.c index cea27514..27cf85dc 100644 --- a/bignum.c +++ b/bignum.c @@ -182,8 +182,10 @@ sexp sexp_bignum_fxmul (sexp ctx, sexp d, sexp a, sexp_uint_t b, int offset) { sexp_luint_t n; sexp_gc_var1(tmp); sexp_gc_preserve1(ctx, tmp); - if ((! d) || (sexp_bignum_length(d)+offset < len)) + if ((! d) || (sexp_bignum_length(d) < len+offset)) d = tmp = sexp_make_bignum(ctx, len); + else + tmp = d; data = sexp_bignum_data(d); for (i=0; i> (sizeof(sexp_uint_t)*8); } if (carry) { - if (sexp_bignum_length(d)+offset <= len) + if (sexp_bignum_length(d) <= len+offset) d = sexp_copy_bignum(ctx, NULL, d, len+offset+1); sexp_bignum_data(d)[len+offset] = carry; }