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;