mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 03:07:29 +02:00
Fix memory leaks
- Freeing the session object depends on the callback return - The session object is malloc'ed when ssl->options.internalCacheOff - wolfSSL_CTX_use_certificate needs to own the cert when KEEP_OUR_CERT because either it is up ref'ed or copied
This commit is contained in:
13
src/ssl.c
13
src/ssl.c
@ -13407,6 +13407,9 @@ int AddSession(WOLFSSL* ssl)
|
|||||||
WOLFSSL_SESSION* session;
|
WOLFSSL_SESSION* session;
|
||||||
int i;
|
int i;
|
||||||
int overwrite = 0;
|
int overwrite = 0;
|
||||||
|
#ifdef HAVE_EXT_CACHE
|
||||||
|
int cbRet = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ssl->options.sessionCacheOff)
|
if (ssl->options.sessionCacheOff)
|
||||||
return 0;
|
return 0;
|
||||||
@ -13673,9 +13676,9 @@ int AddSession(WOLFSSL* ssl)
|
|||||||
|
|
||||||
#ifdef HAVE_EXT_CACHE
|
#ifdef HAVE_EXT_CACHE
|
||||||
if (error == 0 && ssl->ctx->new_sess_cb != NULL)
|
if (error == 0 && ssl->ctx->new_sess_cb != NULL)
|
||||||
ssl->ctx->new_sess_cb(ssl, session);
|
cbRet = ssl->ctx->new_sess_cb(ssl, session);
|
||||||
if (ssl->options.internalCacheOff)
|
if (ssl->options.internalCacheOff && cbRet == 0)
|
||||||
FreeSession(session, 0);
|
FreeSession(session, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
@ -42157,7 +42160,9 @@ err:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ctx->ownOurCert = 0;
|
/* We own the cert because either we up its reference counter
|
||||||
|
* or we create our own copy of the cert object. */
|
||||||
|
ctx->ownOurCert = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Update the available options with public keys. */
|
/* Update the available options with public keys. */
|
||||||
|
Reference in New Issue
Block a user