From b299a37a72077e3c2dfa192a76220e13b8ae8601 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Thu, 28 Sep 2017 16:48:04 +0100 Subject: [PATCH] Add missing calls to pem_free in pk_parse --- library/pkparse.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/pkparse.c b/library/pkparse.c index ea68a3d3c..6ab16e51b 100644 --- a/library/pkparse.c +++ b/library/pkparse.c @@ -1068,7 +1068,10 @@ int pk_parse_key( pk_context *pk, if( ret == 0 ) { if( ( pk_info = pk_info_from_type( POLARSSL_PK_RSA ) ) == NULL ) + { + pem_free( &pem ); return( POLARSSL_ERR_PK_UNKNOWN_PK_ALG ); + } if( ( ret = pk_init_ctx( pk, pk_info ) ) != 0 || ( ret = pk_parse_key_pkcs1_der( pk_rsa( *pk ), @@ -1096,7 +1099,10 @@ int pk_parse_key( pk_context *pk, if( ret == 0 ) { if( ( pk_info = pk_info_from_type( POLARSSL_PK_ECKEY ) ) == NULL ) + { + pem_free( &pem ); return( POLARSSL_ERR_PK_UNKNOWN_PK_ALG ); + } if( ( ret = pk_init_ctx( pk, pk_info ) ) != 0 || ( ret = pk_parse_key_sec1_der( pk_ec( *pk ),