mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
add check on init mutex return value
This commit is contained in:
@ -6710,17 +6710,24 @@ WOLFSSL_EVP_PKEY* wolfSSL_EVP_PKEY_new_ex(void* heap)
|
|||||||
XMEMSET(pkey, 0, sizeof(WOLFSSL_EVP_PKEY));
|
XMEMSET(pkey, 0, sizeof(WOLFSSL_EVP_PKEY));
|
||||||
pkey->heap = heap;
|
pkey->heap = heap;
|
||||||
pkey->type = WOLFSSL_EVP_PKEY_DEFAULT;
|
pkey->type = WOLFSSL_EVP_PKEY_DEFAULT;
|
||||||
|
|
||||||
|
/* init of mutex needs to come before wolfSSL_EVP_PKEY_free */
|
||||||
|
ret = wc_InitMutex(&pkey->refMutex);
|
||||||
|
if (ret != 0){
|
||||||
|
XFREE(pkey, heap, DYNAMIC_TYPE_PUBLIC_KEY);
|
||||||
|
WOLFSSL_MSG("Issue initializing mutex");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef HAVE_FIPS
|
#ifndef HAVE_FIPS
|
||||||
ret = wc_InitRng_ex(&pkey->rng, heap, INVALID_DEVID);
|
ret = wc_InitRng_ex(&pkey->rng, heap, INVALID_DEVID);
|
||||||
#else
|
#else
|
||||||
ret = wc_InitRng(&pkey->rng);
|
ret = wc_InitRng(&pkey->rng);
|
||||||
#endif
|
#endif
|
||||||
pkey->references = 1;
|
pkey->references = 1;
|
||||||
wc_InitMutex(&pkey->refMutex); /* init of mutex needs to come before
|
|
||||||
* wolfSSL_EVP_PKEY_free */
|
|
||||||
if (ret != 0){
|
if (ret != 0){
|
||||||
wolfSSL_EVP_PKEY_free(pkey);
|
wolfSSL_EVP_PKEY_free(pkey);
|
||||||
WOLFSSL_MSG("memory failure");
|
WOLFSSL_MSG("Issue initializing RNG");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user