allow user to free x509 object in static case (no op)

This commit is contained in:
toddouska 2015-09-23 11:20:40 -07:00
parent 2c87cfa983
commit 7393b0eea0
2 changed files with 23 additions and 3 deletions

View File

@ -8988,12 +8988,30 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
#endif /* KEEP_PEER_CERT */
#if defined(KEEP_PEER_CERT) || defined(SESSION_CERTS) || defined(OPENSSSL_EXTRA)
/* user externally called free X509, if dynamic go ahead with free, otherwise
* don't */
static void ExternalFreeX509(WOLFSSL_X509* x509)
{
WOLFSSL_ENTER("ExternalFreeX509");
if (x509) {
if (x509->dynamicMemory) {
FreeX509(x509);
} else {
WOLFSSL_MSG("free called on non dynamic object, not freeing");
}
}
}
#endif /* KEEP_PEER_CERT || SESSION_CERTS || OPENSSSL_EXTRA */
#if defined(KEEP_PEER_CERT) || defined(SESSION_CERTS)
void wolfSSL_FreeX509(WOLFSSL_X509* x509)
{
WOLFSSL_ENTER("wolfSSL_FreeX509");
FreeX509(x509);
ExternalFreeX509(x509);
}
@ -10187,9 +10205,10 @@ WOLFSSL_SESSION* wolfSSL_get1_session(WOLFSSL* ssl) /* what's ref count */
}
void wolfSSL_X509_free(WOLFSSL_X509* buf)
void wolfSSL_X509_free(WOLFSSL_X509* x509)
{
FreeX509(buf);
WOLFSSL_ENTER("wolfSSL_X509_free");
ExternalFreeX509(x509);
}

View File

@ -368,6 +368,7 @@ static INLINE void showPeer(WOLFSSL* ssl)
ShowX509(peer, "peer's cert info:");
else
printf("peer has no cert!\n");
wolfSSL_FreeX509(peer);
#endif
printf("SSL version is %s\n", wolfSSL_get_version(ssl));