diff --git a/src/x509.c b/src/x509.c index 1fc6c289af..d130f9fe19 100644 --- a/src/x509.c +++ b/src/x509.c @@ -14121,7 +14121,9 @@ int wolfSSL_X509_check_ip_asc(WOLFSSL_X509 *x, const char *ipasc, } #ifdef WOLFSSL_SMALL_STACK - XFREE(dCert, x->heap, DYNAMIC_TYPE_DCERT); + if (x != NULL) { + XFREE(dCert, x->heap, DYNAMIC_TYPE_DCERT); + } #endif return ret; diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 74fa6feb2d..5b15367f8e 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -13939,6 +13939,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes_cbc_test(void) if ((bigCipher == NULL) || (bigPlain == NULL)) { XFREE(bigCipher, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); + XFREE(bigPlain, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); ERROR_OUT(WC_TEST_RET_ENC_NC, out); } #else @@ -35116,6 +35117,16 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t curve25519_test(void) (void)x; WOLFSSL_ENTER("curve25519_test"); + /* wc_FreeRng is always called on exit. Therefore wc_InitRng should be + * called before any exit goto's */ +#ifndef HAVE_FIPS + ret = wc_InitRng_ex(&rng, HEAP_HINT, devId); +#else + ret = wc_InitRng(&rng); +#endif + if (ret != 0) + return WC_TEST_RET_ENC_EC(ret); + #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) userA = wc_curve25519_new(HEAP_HINT, devId, &ret); if (ret != 0) @@ -35132,14 +35143,6 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t curve25519_test(void) wc_curve25519_init_ex(pubKey, HEAP_HINT, devId); #endif -#ifndef HAVE_FIPS - ret = wc_InitRng_ex(&rng, HEAP_HINT, devId); -#else - ret = wc_InitRng(&rng); -#endif - if (ret != 0) - ERROR_OUT(WC_TEST_RET_ENC_EC(ret), cleanup); - /* make curve25519 keys */ ret = wc_curve25519_make_key(&rng, 32, userA); if (ret != 0)