From c3dba3f9af2d78213e6ab38f38e99934a345bb50 Mon Sep 17 00:00:00 2001 From: Elms Date: Wed, 21 Oct 2020 09:59:39 -0700 Subject: [PATCH] Add additional checks to sp_ecc_point_new --- wolfcrypt/src/sp_dsp32.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/sp_dsp32.c b/wolfcrypt/src/sp_dsp32.c index 0b31f25af..38d6dc721 100644 --- a/wolfcrypt/src/sp_dsp32.c +++ b/wolfcrypt/src/sp_dsp32.c @@ -117,7 +117,6 @@ static const sp_point p256_base __attribute__((aligned(128))) = { static int sp_ecc_point_new_ex(void* heap, sp_point* sp, sp_point** p) { int ret = MP_OKAY; - (void)heap; if (p == NULL) { ret = MEMORY_E; @@ -125,8 +124,16 @@ static int sp_ecc_point_new_ex(void* heap, sp_point* sp, sp_point** p) #if defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK) (void)sp; *p = (sp_point*)XMALLOC(sizeof(sp_point), heap, DYNAMIC_TYPE_ECC); + if (*p == NULL) { + ret = MEMORY_E; + } #else - *p = sp; + (void)heap; + if (sp == NULL) { + ret = MEMORY_E; + } else { + *p = sp; + } #endif }