Skip to content

Commit

Permalink
Fix possible AES leaks detected with sanitizer and clang-tidy.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarske committed Oct 5, 2024
1 parent b9de3bb commit 59389a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions wolfcrypt/src/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -14060,11 +14060,16 @@ static WARN_UNUSED_RESULT int AesSivCipher(
}
}

aes->isAllocated = 0;
wc_AesFree(aes);
#ifdef WOLFSSL_SMALL_STACK
XFREE(aes, NULL, DYNAMIC_TYPE_AES);
if (aes != NULL)
#endif
{
aes->isAllocated = 0;
wc_AesFree(aes);
#ifdef WOLFSSL_SMALL_STACK
XFREE(aes, NULL, DYNAMIC_TYPE_AES);
#endif
}

return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion wolfcrypt/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -15913,8 +15913,8 @@ static wc_test_ret_t aesccm_128_test(void)
XMEMSET(p2, 0, sizeof(p2));
XMEMSET(iv2, 0, sizeof(iv2));

#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
wc_AesFree(enc);
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
enc = wc_AesNew(HEAP_HINT, devId);
if (enc == NULL)
ERROR_OUT(WC_TEST_RET_ENC_EC(MEMORY_E), out);
Expand Down

0 comments on commit 59389a0

Please sign in to comment.