From 1b2b3de2c99a36d0162c07a4baccd4276a427931 Mon Sep 17 00:00:00 2001 From: David Garske Date: Wed, 26 Aug 2020 09:48:46 -0700 Subject: [PATCH] Fixes for missing free calls on hash tests. --- tests/api.c | 8 ++++++++ tests/hash.c | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/tests/api.c b/tests/api.c index 9200108fb..fccdd650f 100644 --- a/tests/api.c +++ b/tests/api.c @@ -33346,6 +33346,10 @@ static void test_wolfSSL_EVP_PKEY_sign(void) SHA256_Init(&c); SHA256_Update(&c, in, inlen); SHA256_Final(hash, &c); +#ifdef WOLFSSL_SMALL_STACK_CACHE + /* workaround for small stack cache case */ + wc_Sha256Free((wc_Sha256*)&c); +#endif AssertNotNull(rsa = RSA_generate_key(2048, 3, NULL, NULL)); AssertNotNull(pkey = wolfSSL_EVP_PKEY_new()); @@ -35759,6 +35763,10 @@ static void test_wolfSSL_RSA_verify() SHA256_Init(&c); SHA256_Update(&c, text, strlen(text)); SHA256_Final(hash, &c); +#ifdef WOLFSSL_SMALL_STACK_CACHE + /* workaround for small stack cache case */ + wc_Sha256Free((wc_Sha256*)&c); +#endif /* read privete key file */ fp = XFOPEN(svrKeyFile, "r"); diff --git a/tests/hash.c b/tests/hash.c index be9966ac5..c99eb2908 100644 --- a/tests/hash.c +++ b/tests/hash.c @@ -320,6 +320,7 @@ int md5_test(void) if (XMEMCMP(hash, test_md5[i].output, WC_MD5_DIGEST_SIZE) != 0) return -5 - i; } + wc_Md5Free(&md5); return 0; } @@ -380,6 +381,7 @@ int sha_test(void) if (XMEMCMP(hash, test_sha[i].output, WC_SHA_DIGEST_SIZE) != 0) return -10 - i; } + wc_ShaFree(&sha); return 0; } @@ -426,6 +428,7 @@ int sha224_test(void) if (XMEMCMP(hash, test_sha[i].output, WC_SHA224_DIGEST_SIZE) != 0) return -10 - i; } + wc_Sha224Free(&sha); return 0; } @@ -475,6 +478,7 @@ int sha256_test(void) if (XMEMCMP(hash, test_sha[i].output, WC_SHA256_DIGEST_SIZE) != 0) return -10 - i; } + wc_Sha256Free(&sha); return 0; } @@ -529,6 +533,7 @@ int sha512_test(void) if (XMEMCMP(hash, test_sha[i].output, WC_SHA512_DIGEST_SIZE) != 0) return -10 - i; } + wc_Sha512Free(&sha); return 0; } @@ -581,6 +586,7 @@ int sha384_test(void) if (XMEMCMP(hash, test_sha[i].output, WC_SHA384_DIGEST_SIZE) != 0) return -10 - i; } + wc_Sha384Free(&sha); return 0; }