save heap before Free in Delete wrappers

This commit is contained in:
Jeremiah Mackey
2026-04-16 17:14:05 +00:00
parent f086e91cbf
commit 625ea89284
3 changed files with 9 additions and 3 deletions
+3 -1
View File
@@ -13661,10 +13661,12 @@ Aes* wc_AesNew_Label(const char* label, void* heap, int devId,
int wc_AesDelete(Aes *aes, Aes** aes_p)
{
void* heap;
if (aes == NULL)
return BAD_FUNC_ARG;
heap = aes->heap;
wc_AesFree(aes);
XFREE(aes, aes->heap, DYNAMIC_TYPE_AES);
XFREE(aes, heap, DYNAMIC_TYPE_AES);
if (aes_p != NULL)
*aes_p = NULL;
return 0;
+3 -1
View File
@@ -866,12 +866,14 @@ wc_HashAlg* wc_HashNew(enum wc_HashType type, void* heap, int devId,
int wc_HashDelete(wc_HashAlg *hash, wc_HashAlg **hash_p) {
int ret;
void* heap;
if (hash == NULL)
return BAD_FUNC_ARG;
heap = hash->heap;
ret = wc_HashFree(hash, hash->type);
if (ret < 0)
return ret;
XFREE(hash, hash->heap, DYNAMIC_TYPE_HASHES);
XFREE(hash, heap, DYNAMIC_TYPE_HASHES);
if (hash_p != NULL)
*hash_p = NULL;
return 0;
+3 -1
View File
@@ -337,10 +337,12 @@ MlKemKey* wc_MlKemKey_New(int type, void* heap, int devId)
int wc_MlKemKey_Delete(MlKemKey* key, MlKemKey** key_p)
{
void* heap;
if (key == NULL)
return BAD_FUNC_ARG;
heap = key->heap;
wc_MlKemKey_Free(key);
XFREE(key, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(key, heap, DYNAMIC_TYPE_TMP_BUFFER);
if (key_p != NULL)
*key_p = NULL;