diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index fc0b74bf6..642fd908e 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -8874,7 +8874,7 @@ static int _sp_exptmod_nct(sp_int* b, sp_int* e, sp_int* m, sp_int* r) /* Sqaure until we find bit that is 1 or there's less than a * window of bits left. */ - while ((i >= 0) || (c >= winBits)) { + while (err == MP_OKAY && ((i >= 0) || (c >= winBits))) { sp_digit n2 = n; int c2 = c; int i2 = i;