From 0cfa4235660d8930d75ce7efb0e657df2b72126b Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 27 Dec 2012 10:08:44 -0800 Subject: [PATCH] fixed mp_add_d overflow --- ctaocrypt/src/integer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ctaocrypt/src/integer.c b/ctaocrypt/src/integer.c index 388c4f0d5..000669db5 100644 --- a/ctaocrypt/src/integer.c +++ b/ctaocrypt/src/integer.c @@ -3792,8 +3792,10 @@ int mp_add_d (mp_int* a, mp_digit b, mp_int* c) *tmpc++ &= MP_MASK; } /* set final carry */ - ix++; - *tmpc++ = mu; + if (mu != 0 && ix < c->alloc) { + ix++; + *tmpc++ = mu; + } /* setup size */ c->used = a->used + 1;