Skip to content

Commit

Permalink
wolfcrypt/test/test.c: fix memory leak in dsa_test().
Browse files Browse the repository at this point in the history
  • Loading branch information
douzzer committed Nov 29, 2023
1 parent 962bf88 commit 93ab397
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions wolfcrypt/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -20683,6 +20683,14 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t dsa_test(void)
if (answer != 1)
ERROR_OUT(WC_TEST_RET_ENC_NC, out);

wc_FreeDsaKey(key);
key_inited = 0;

ret = wc_InitDsaKey_h(key, NULL);
if (ret != 0)
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
key_inited = 1;

#ifdef WOLFSSL_KEY_GEN
{
int derSz = 0;
Expand Down Expand Up @@ -20727,16 +20735,6 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t dsa_test(void)

out:

#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
if (key) {
#endif
ret = wc_InitDsaKey_h(key, NULL);
if (ret != 0)
ret = WC_TEST_RET_ENC_EC(ret);
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
}
#endif

#ifdef WOLFSSL_KEY_GEN
if (der)
XFREE(der, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
Expand Down

0 comments on commit 93ab397

Please sign in to comment.