Skip to content

Commit a66137d

Browse files
authored
Merge pull request #7062 from lealem47/leaks
Cleanup leaks in api.c and benchmark.c
2 parents 8acee81 + 5fd0470 commit a66137d

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
@@ -68772,6 +68772,12 @@ static int test_dtls13_early_data(void)
6877268772

6877368773
ExpectTrue(wolfSSL_session_reused(ssl_c));
6877468774
ExpectTrue(wolfSSL_session_reused(ssl_s));
68775+
68776+
wolfSSL_SESSION_free(sess);
68777+
wolfSSL_free(ssl_c);
68778+
wolfSSL_free(ssl_s);
68779+
wolfSSL_CTX_free(ctx_c);
68780+
wolfSSL_CTX_free(ctx_s);
6877568781
#endif
6877668782
return EXPECT_RESULT();
6877768783
}

wolfcrypt/benchmark/benchmark.c

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

2944-
if (bench_plain == NULL)
2944+
if (bench_plain == NULL) {
2945+
XFCLOSE(file);
29452946
goto exit;
2947+
}
29462948

29472949
if ((size_t)XFREAD(bench_plain, 1, rawSz, file)
29482950
!= (size_t)rawSz) {
29492951
XFCLOSE(file);
29502952
goto exit;
29512953
}
2954+
2955+
XFCLOSE(file);
29522956
}
29532957
else {
29542958
XMEMSET(bench_plain, 0, (size_t)bench_buf_size);
@@ -2984,14 +2988,18 @@ static void* benchmarks_do(void* args)
29842988
bench_cipher = (byte*)XMALLOC((size_t)bench_buf_size + 16*2,
29852989
HEAP_HINT, DYNAMIC_TYPE_WOLF_BIGINT);
29862990

2987-
if (bench_cipher == NULL)
2991+
if (bench_cipher == NULL) {
2992+
XFCLOSE(file);
29882993
goto exit;
2994+
}
29892995

29902996
if ((size_t)XFREAD(bench_cipher, 1, rawSz, file)
29912997
!= (size_t)rawSz) {
29922998
XFCLOSE(file);
29932999
goto exit;
29943000
}
3001+
3002+
XFCLOSE(file);
29953003
}
29963004
else {
29973005
XMEMSET(bench_cipher, 0, (size_t)bench_buf_size);

0 commit comments

Comments
 (0)