Skip to content

Commit 59389a0

Browse files
committed
Fix possible AES leaks detected with sanitizer and clang-tidy.
1 parent b9de3bb commit 59389a0

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

wolfcrypt/src/aes.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14060,11 +14060,16 @@ static WARN_UNUSED_RESULT int AesSivCipher(
1406014060
}
1406114061
}
1406214062

14063-
aes->isAllocated = 0;
14064-
wc_AesFree(aes);
1406514063
#ifdef WOLFSSL_SMALL_STACK
14066-
XFREE(aes, NULL, DYNAMIC_TYPE_AES);
14064+
if (aes != NULL)
1406714065
#endif
14066+
{
14067+
aes->isAllocated = 0;
14068+
wc_AesFree(aes);
14069+
#ifdef WOLFSSL_SMALL_STACK
14070+
XFREE(aes, NULL, DYNAMIC_TYPE_AES);
14071+
#endif
14072+
}
1406814073

1406914074
return ret;
1407014075
}

wolfcrypt/test/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15913,8 +15913,8 @@ static wc_test_ret_t aesccm_128_test(void)
1591315913
XMEMSET(p2, 0, sizeof(p2));
1591415914
XMEMSET(iv2, 0, sizeof(iv2));
1591515915

15916-
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
1591715916
wc_AesFree(enc);
15917+
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
1591815918
enc = wc_AesNew(HEAP_HINT, devId);
1591915919
if (enc == NULL)
1592015920
ERROR_OUT(WC_TEST_RET_ENC_EC(MEMORY_E), out);

0 commit comments

Comments
 (0)