From 4da9ade29047f4fc1e1af213b8e9b75b26654099 Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Mon, 25 Jan 2021 19:29:07 +0100 Subject: [PATCH] Use wolfSSL_X509_free to free ourCert --- src/internal.c | 3 +-- src/ssl.c | 23 +++++++---------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/internal.c b/src/internal.c index e2fdbcc71..29d01de55 100644 --- a/src/internal.c +++ b/src/internal.c @@ -1850,8 +1850,7 @@ void SSL_CtxResourceFree(WOLFSSL_CTX* ctx) FreeDer(&ctx->certificate); #ifdef KEEP_OUR_CERT if (ctx->ourCert && ctx->ownOurCert) { - FreeX509(ctx->ourCert); - XFREE(ctx->ourCert, ctx->heap, DYNAMIC_TYPE_X509); + wolfSSL_X509_free(ctx->ourCert); ctx->ourCert = NULL; } #endif /* KEEP_OUR_CERT */ diff --git a/src/ssl.c b/src/ssl.c index 61ffe8c5d..f577cf957 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -5461,11 +5461,8 @@ int ProcessBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff, if (ssl->buffers.weOwnCert) { FreeDer(&ssl->buffers.certificate); #ifdef KEEP_OUR_CERT - FreeX509(ssl->ourCert); - if (ssl->ourCert) { - XFREE(ssl->ourCert, ssl->heap, DYNAMIC_TYPE_X509); - ssl->ourCert = NULL; - } + wolfSSL_X509_free(ssl->ourCert); + ssl->ourCert = NULL; #endif } ssl->buffers.certificate = der; @@ -5478,10 +5475,8 @@ int ProcessBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff, FreeDer(&ctx->certificate); /* Make sure previous is free'd */ #ifdef KEEP_OUR_CERT if (ctx->ourCert) { - if (ctx->ownOurCert) { - FreeX509(ctx->ourCert); - XFREE(ctx->ourCert, ctx->heap, DYNAMIC_TYPE_X509); - } + if (ctx->ownOurCert) + wolfSSL_X509_free(ctx->ourCert); ctx->ourCert = NULL; } #endif @@ -14772,11 +14767,8 @@ int wolfSSL_set_compression(WOLFSSL* ssl) WOLFSSL_MSG("Unloading cert"); FreeDer(&ssl->buffers.certificate); #ifdef KEEP_OUR_CERT - FreeX509(ssl->ourCert); - if (ssl->ourCert) { - XFREE(ssl->ourCert, ssl->heap, DYNAMIC_TYPE_X509); - ssl->ourCert = NULL; - } + wolfSSL_X509_free(ssl->ourCert); + ssl->ourCert = NULL; #endif ssl->buffers.weOwnCert = 0; } @@ -42189,8 +42181,7 @@ err: x->derCert->length); #ifdef KEEP_OUR_CERT if (ctx->ourCert != NULL && ctx->ownOurCert) { - FreeX509(ctx->ourCert); - XFREE(ctx->ourCert, ctx->heap, DYNAMIC_TYPE_X509); + wolfSSL_X509_free(ctx->ourCert); } #ifndef WOLFSSL_X509_STORE_CERTS ctx->ourCert = x;