Skip to content

Commit

Permalink
Merge pull request wolfSSL#7062 from lealem47/leaks
Browse files Browse the repository at this point in the history
Cleanup leaks in api.c and benchmark.c
  • Loading branch information
cconlon authored Dec 13, 2023
2 parents 8acee81 + 5fd0470 commit a66137d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -68772,6 +68772,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();
}
Expand Down
12 changes: 10 additions & 2 deletions wolfcrypt/benchmark/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -2941,14 +2941,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);
Expand Down Expand Up @@ -2984,14 +2988,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);
Expand Down

0 comments on commit a66137d

Please sign in to comment.