From 74cd2fd910b2449b002b3b3c1523f9287272d47f Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 22 Apr 2022 09:15:52 -0700 Subject: [PATCH] Fix for integer.c possible uses of mp_int input with DP NULL. --- wolfcrypt/src/integer.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index c75eab1e3..54c8b1eca 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -4378,6 +4378,10 @@ int mp_add_d (mp_int* a, mp_digit b, mp_int* c) // NOLINT(misc-no-recursion) /* destination alias */ tmpc = c->dp; + if (tmpa == NULL || tmpc == NULL) { + return MP_MEM; + } + /* if a is positive */ if (a->sign == MP_ZPOS) { /* add digit, after this we're propagating @@ -4462,6 +4466,10 @@ int mp_sub_d (mp_int * a, mp_digit b, mp_int * c) // NOLINT(misc-no-recursion) tmpa = a->dp; tmpc = c->dp; + if (tmpa == NULL || tmpc == NULL) { + return MP_MEM; + } + /* if a <= b simply fix the single digit */ if ((a->used == 1 && a->dp[0] <= b) || a->used == 0) { if (a->used == 1) {