Fix possible AES leaks detected with sanitizer and clang-tidy.

This commit is contained in:
David Garske
2024-10-05 11:52:22 -07:00
parent b9de3bbf1a
commit 59389a0ef5
2 changed files with 9 additions and 4 deletions

View File

@@ -14060,11 +14060,16 @@ static WARN_UNUSED_RESULT int AesSivCipher(
} }
} }
#ifdef WOLFSSL_SMALL_STACK
if (aes != NULL)
#endif
{
aes->isAllocated = 0; aes->isAllocated = 0;
wc_AesFree(aes); wc_AesFree(aes);
#ifdef WOLFSSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(aes, NULL, DYNAMIC_TYPE_AES); XFREE(aes, NULL, DYNAMIC_TYPE_AES);
#endif #endif
}
return ret; return ret;
} }

View File

@@ -15913,8 +15913,8 @@ static wc_test_ret_t aesccm_128_test(void)
XMEMSET(p2, 0, sizeof(p2)); XMEMSET(p2, 0, sizeof(p2));
XMEMSET(iv2, 0, sizeof(iv2)); XMEMSET(iv2, 0, sizeof(iv2));
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
wc_AesFree(enc); wc_AesFree(enc);
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
enc = wc_AesNew(HEAP_HINT, devId); enc = wc_AesNew(HEAP_HINT, devId);
if (enc == NULL) if (enc == NULL)
ERROR_OUT(WC_TEST_RET_ENC_EC(MEMORY_E), out); ERROR_OUT(WC_TEST_RET_ENC_EC(MEMORY_E), out);