Skip to content

Commit

Permalink
Free'ing ctx->srp has to be reference counted as well
Browse files Browse the repository at this point in the history
  • Loading branch information
julek-wolfssl committed Jan 24, 2025
1 parent 40500e4 commit 829c2a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
11 changes: 10 additions & 1 deletion src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3023,7 +3023,16 @@ void FreeSSL_Ctx(WOLFSSL_CTX* ctx)

if (isZero) {
WOLFSSL_MSG("CTX ref count down to 0, doing full free");

#if defined(OPENSSL_EXTRA) && defined(WOLFCRYPT_HAVE_SRP) && \
!defined(NO_SHA256) && !defined(WC_NO_RNG)
if (ctx->srp != NULL) {
XFREE(ctx->srp_password, ctx->heap, DYNAMIC_TYPE_SRP);
ctx->srp_password = NULL;
wc_SrpTerm(ctx->srp);
XFREE(ctx->srp, ctx->heap, DYNAMIC_TYPE_SRP);
ctx->srp = NULL;
}
#endif
SSL_CtxResourceFree(ctx);
#if defined(HAVE_SESSION_TICKET) && !defined(NO_WOLFSSL_SERVER) && \
!defined(WOLFSSL_NO_DEF_TICKET_ENC_CB) && !defined(NO_TLS)
Expand Down
10 changes: 0 additions & 10 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1194,16 +1194,6 @@ void wolfSSL_CTX_free(WOLFSSL_CTX* ctx)
{
WOLFSSL_ENTER("wolfSSL_CTX_free");
if (ctx) {
#if defined(OPENSSL_EXTRA) && defined(WOLFCRYPT_HAVE_SRP) \
&& !defined(NO_SHA256) && !defined(WC_NO_RNG)
if (ctx->srp != NULL) {
XFREE(ctx->srp_password, ctx->heap, DYNAMIC_TYPE_SRP);
ctx->srp_password = NULL;
wc_SrpTerm(ctx->srp);
XFREE(ctx->srp, ctx->heap, DYNAMIC_TYPE_SRP);
ctx->srp = NULL;
}
#endif
FreeSSL_Ctx(ctx);
}

Expand Down

0 comments on commit 829c2a0

Please sign in to comment.