mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-05 12:20:52 +02:00
save heap before Free in Delete wrappers
This commit is contained in:
+3
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user