Fixed potential memory leak when failing to resume a session

This commit is contained in:
Paul Bakker 2013-09-11 11:45:41 +02:00
parent 78020fe72c
commit a565aceea1
2 changed files with 8 additions and 0 deletions

View File

@ -2,6 +2,7 @@ PolarSSL ChangeLog
= Branch 1.2
Bugfix
* Fixed potential memory leak when failing to resume a session
* Minor fixes
Security

View File

@ -2345,6 +2345,13 @@ int ssl_parse_certificate( ssl_context *ssl )
return( POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE );
}
/* In case we tried to reuse a session but it failed */
if( ssl->session_negotiate->peer_cert != NULL )
{
x509_free( ssl->session_negotiate->peer_cert );
free( ssl->session_negotiate->peer_cert );
}
if( ( ssl->session_negotiate->peer_cert = (x509_cert *) malloc(
sizeof( x509_cert ) ) ) == NULL )
{