diff --git a/ChangeLog b/ChangeLog index a9654e639..a4c11f670 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ PolarSSL ChangeLog += Master +Bugfix + * Fixed memory leak in ssl_free() and ssl_reset() for active session + = Version 1.2.5 released 2013-02-02 Changes * Allow enabling of dummy error_strerror() to support some use-cases diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 4194ac05c..44cb92bc5 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -3025,6 +3025,13 @@ int ssl_session_reset( ssl_context *ssl ) ssl->transform = NULL; } + if( ssl->session ) + { + ssl_session_free( ssl->session ); + free( ssl->session ); + ssl->session = NULL; + } + if( ( ret = ssl_handshake_init( ssl ) ) != 0 ) return( ret ); @@ -3891,6 +3898,12 @@ void ssl_free( ssl_context *ssl ) free( ssl->session_negotiate ); } + if( ssl->session ) + { + ssl_session_free( ssl->session ); + free( ssl->session ); + } + if ( ssl->hostname != NULL) { memset( ssl->hostname, 0, ssl->hostname_len );