From f17dfa5b0324ade1f10115e91125b420a9bad85b Mon Sep 17 00:00:00 2001 From: David Garske Date: Wed, 9 Mar 2016 09:15:00 -0800 Subject: [PATCH] Moved the x509 XFREE to outside the FreeX509 function. Internally FreeX509 is only used in two places. One is for the ssl->peerCert, which is not dynamic anyways. The second is in the ExternalFreeX509 where it calls FreeX509 if its dynamic and will XFREE there. --- src/internal.c | 2 -- src/ssl.c | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/internal.c b/src/internal.c index 91caeeb3f..911bef531 100644 --- a/src/internal.c +++ b/src/internal.c @@ -1695,8 +1695,6 @@ void FreeX509(WOLFSSL_X509* x509) #endif /* OPENSSL_EXTRA */ if (x509->altNames) FreeAltNames(x509->altNames, NULL); - if (x509->dynamicMemory) - XFREE(x509, NULL, DYNAMIC_TYPE_X509); } diff --git a/src/ssl.c b/src/ssl.c index 8e788a4bf..29c6f8ca6 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -9424,6 +9424,7 @@ static void ExternalFreeX509(WOLFSSL_X509* x509) if (x509) { if (x509->dynamicMemory) { FreeX509(x509); + XFREE(x509, NULL, DYNAMIC_TYPE_X509); } else { WOLFSSL_MSG("free called on non dynamic object, not freeing"); }