From 72e53ca1a40e0cb65d6a3b07a86dafc3572e7350 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Mon, 20 Mar 2023 07:17:25 -0700 Subject: [PATCH] handle failing RNG init when creating PKEY --- wolfcrypt/src/evp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/evp.c b/wolfcrypt/src/evp.c index 477179b4b..1925b23ef 100644 --- a/wolfcrypt/src/evp.c +++ b/wolfcrypt/src/evp.c @@ -9496,7 +9496,8 @@ WOLFSSL_EVP_PKEY* wolfSSL_EVP_PKEY_new_ex(void* heap) ret = wc_InitRng(&pkey->rng); #endif if (ret != 0){ - wolfSSL_EVP_PKEY_free(pkey); + /* Free directly since mutex for ref count not set yet */ + XFREE(pkey, heap, DYNAMIC_TYPE_PUBLIC_KEY); WOLFSSL_MSG("Issue initializing RNG"); return NULL; }