From a6a89d3316bbe638f210240f853b1461a3a8ee95 Mon Sep 17 00:00:00 2001 From: David Garske Date: Thu, 21 Apr 2022 13:55:19 -0700 Subject: [PATCH] Fix for integer.c `s_mp_add` output to make sure it grows if not set. --- wolfcrypt/src/integer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index e52152771..c75eab1e3 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -1713,7 +1713,7 @@ int s_mp_add (mp_int * a, mp_int * b, mp_int * c) } /* init result */ - if (c->alloc < max_ab + 1) { + if (c->dp == NULL || c->alloc < max_ab + 1) { if ((res = mp_grow (c, max_ab + 1)) != MP_OKAY) { return res; } @@ -1757,7 +1757,7 @@ int s_mp_add (mp_int * a, mp_int * b, mp_int * c) if (min_ab != max_ab) { for (; i < max_ab; i++) { /* T[i] = X[i] + U */ - *tmpc = x->dp[i] + u; // NOLINT(clang-analyzer-core.NullDereference) /* clang-tidy 13 false positive */ + *tmpc = x->dp[i] + u; /* U = carry bit of T[i] */ u = *tmpc >> ((mp_digit)DIGIT_BIT);