Skip to content

Commit 5fd0470

Browse files
author
Lealem Amedie
committed
Cleanup leaks in api.c and benchmark.c
1 parent c4b77ad commit 5fd0470

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

tests/api.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68501,6 +68501,12 @@ static int test_dtls13_early_data(void)
6850168501

6850268502
ExpectTrue(wolfSSL_session_reused(ssl_c));
6850368503
ExpectTrue(wolfSSL_session_reused(ssl_s));
68504+
68505+
wolfSSL_SESSION_free(sess);
68506+
wolfSSL_free(ssl_c);
68507+
wolfSSL_free(ssl_s);
68508+
wolfSSL_CTX_free(ctx_c);
68509+
wolfSSL_CTX_free(ctx_s);
6850468510
#endif
6850568511
return EXPECT_RESULT();
6850668512
}

wolfcrypt/benchmark/benchmark.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,14 +2708,18 @@ static void* benchmarks_do(void* args)
27082708
bench_plain = (byte*)XMALLOC((size_t)bench_buf_size + 16*2,
27092709
HEAP_HINT, DYNAMIC_TYPE_WOLF_BIGINT);
27102710

2711-
if (bench_plain == NULL)
2711+
if (bench_plain == NULL) {
2712+
XFCLOSE(file);
27122713
goto exit;
2714+
}
27132715

27142716
if ((size_t)XFREAD(bench_plain, 1, rawSz, file)
27152717
!= (size_t)rawSz) {
27162718
XFCLOSE(file);
27172719
goto exit;
27182720
}
2721+
2722+
XFCLOSE(file);
27192723
}
27202724
else {
27212725
XMEMSET(bench_plain, 0, (size_t)bench_buf_size);
@@ -2751,14 +2755,18 @@ static void* benchmarks_do(void* args)
27512755
bench_cipher = (byte*)XMALLOC((size_t)bench_buf_size + 16*2,
27522756
HEAP_HINT, DYNAMIC_TYPE_WOLF_BIGINT);
27532757

2754-
if (bench_cipher == NULL)
2758+
if (bench_cipher == NULL) {
2759+
XFCLOSE(file);
27552760
goto exit;
2761+
}
27562762

27572763
if ((size_t)XFREAD(bench_cipher, 1, rawSz, file)
27582764
!= (size_t)rawSz) {
27592765
XFCLOSE(file);
27602766
goto exit;
27612767
}
2768+
2769+
XFCLOSE(file);
27622770
}
27632771
else {
27642772
XMEMSET(bench_cipher, 0, (size_t)bench_buf_size);

0 commit comments

Comments
 (0)