Skip to content

Commit 93ab397

Browse files
committed
wolfcrypt/test/test.c: fix memory leak in dsa_test().
1 parent 962bf88 commit 93ab397

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

wolfcrypt/test/test.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20683,6 +20683,14 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t dsa_test(void)
2068320683
if (answer != 1)
2068420684
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
2068520685

20686+
wc_FreeDsaKey(key);
20687+
key_inited = 0;
20688+
20689+
ret = wc_InitDsaKey_h(key, NULL);
20690+
if (ret != 0)
20691+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
20692+
key_inited = 1;
20693+
2068620694
#ifdef WOLFSSL_KEY_GEN
2068720695
{
2068820696
int derSz = 0;
@@ -20727,16 +20735,6 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t dsa_test(void)
2072720735

2072820736
out:
2072920737

20730-
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
20731-
if (key) {
20732-
#endif
20733-
ret = wc_InitDsaKey_h(key, NULL);
20734-
if (ret != 0)
20735-
ret = WC_TEST_RET_ENC_EC(ret);
20736-
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
20737-
}
20738-
#endif
20739-
2074020738
#ifdef WOLFSSL_KEY_GEN
2074120739
if (der)
2074220740
XFREE(der, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);

0 commit comments

Comments
 (0)