Fix potential double-free in mbedtls_ssl_conf_psk()
diff --git a/ChangeLog b/ChangeLog
index c9e48e2..f0c71fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
mbed TLS ChangeLog (Sorted per branch, date)
+= mbed TLS 2.1.2 released 2015-??-??
+
+Security
+ * Fix potential double-free if mbedtls_conf_psk() is called repeatedly on
+ the same mbedtls_ssl_config object and some memory allocations fail.
+ Found by Guido Vranken. Can not be forced remotely.
+
= mbed TLS 2.1.1 released 2015-09-17
Security
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index d9b05fd..c1e29c7 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -5707,7 +5707,9 @@
( conf->psk_identity = mbedtls_calloc( 1, psk_identity_len ) ) == NULL )
{
mbedtls_free( conf->psk );
+ mbedtls_free( conf->psk_identity );
conf->psk = NULL;
+ conf->psk_identity = NULL;
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}