From 5fd0470f7674e6e5b93e504743d8be013e0a5e9b Mon Sep 17 00:00:00 2001 From: Lealem Amedie Date: Wed, 13 Dec 2023 13:00:52 -0700 Subject: [PATCH] Cleanup leaks in api.c and benchmark.c --- tests/api.c | 6 ++++++ wolfcrypt/benchmark/benchmark.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/api.c b/tests/api.c index 38673e45b..b4d6eaea1 100644 --- a/tests/api.c +++ b/tests/api.c @@ -68501,6 +68501,12 @@ static int test_dtls13_early_data(void) ExpectTrue(wolfSSL_session_reused(ssl_c)); ExpectTrue(wolfSSL_session_reused(ssl_s)); + + wolfSSL_SESSION_free(sess); + wolfSSL_free(ssl_c); + wolfSSL_free(ssl_s); + wolfSSL_CTX_free(ctx_c); + wolfSSL_CTX_free(ctx_s); #endif return EXPECT_RESULT(); } diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 55f8e6c4d..65955f9a0 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -2708,14 +2708,18 @@ static void* benchmarks_do(void* args) bench_plain = (byte*)XMALLOC((size_t)bench_buf_size + 16*2, HEAP_HINT, DYNAMIC_TYPE_WOLF_BIGINT); - if (bench_plain == NULL) + if (bench_plain == NULL) { + XFCLOSE(file); goto exit; + } if ((size_t)XFREAD(bench_plain, 1, rawSz, file) != (size_t)rawSz) { XFCLOSE(file); goto exit; } + + XFCLOSE(file); } else { XMEMSET(bench_plain, 0, (size_t)bench_buf_size); @@ -2751,14 +2755,18 @@ static void* benchmarks_do(void* args) bench_cipher = (byte*)XMALLOC((size_t)bench_buf_size + 16*2, HEAP_HINT, DYNAMIC_TYPE_WOLF_BIGINT); - if (bench_cipher == NULL) + if (bench_cipher == NULL) { + XFCLOSE(file); goto exit; + } if ((size_t)XFREAD(bench_cipher, 1, rawSz, file) != (size_t)rawSz) { XFCLOSE(file); goto exit; } + + XFCLOSE(file); } else { XMEMSET(bench_cipher, 0, (size_t)bench_buf_size);