From bc9a451b5111758585f62933fe0d079fdc9a2fb1 Mon Sep 17 00:00:00 2001 From: cameronrich Date: Sun, 2 Jan 2011 22:38:59 +0000 Subject: [PATCH] fixed some valgrind detected issues. git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@185 9a5d90b5-6617-0410-8a86-bb477d3ed2e3 --- crypto/bigint.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crypto/bigint.c b/crypto/bigint.c index d8bd868d3..634c1980d 100644 --- a/crypto/bigint.c +++ b/crypto/bigint.c @@ -826,11 +826,10 @@ static bigint *regular_multiply(BI_CTX *ctx, bigint *bia, bigint *bib, do { comp carry = 0; - comp b = *sb++; int r_index = i; j = 0; - if (outer_partial) + if (outer_partial && outer_partial-i > 0 && outer_partial < n) { r_index = outer_partial-1; j = outer_partial-i-1; @@ -843,7 +842,7 @@ static bigint *regular_multiply(BI_CTX *ctx, bigint *bia, bigint *bib, break; } - long_comp tmp = sr[r_index] + ((long_comp)sa[j])*b + carry; + long_comp tmp = sr[r_index] + ((long_comp)sa[j])*sb[i] + carry; sr[r_index++] = (comp)tmp; /* downsize */ carry = tmp >> COMP_BIT_SIZE; } while (++j < n); @@ -945,7 +944,7 @@ static bigint *regular_square(BI_CTX *ctx, bigint *bi) { int t = bi->size; int i = 0, j; - bigint *biR = alloc(ctx, t*2); + bigint *biR = alloc(ctx, t*2+1); comp *w = biR->comps; comp *x = bi->comps; long_comp carry;