Add pem_free() to other error paths in pk_parse_public_key()
@@ -1454,9 +1454,13 @@ int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx,
{
p = pem.buf;
if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA )) == NULL )
+ {
+ mbedtls_pem_free( &pem );
return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG );
+ }
- if( ( ret = mbedtls_pk_setup( ctx, pk_info ) ) != 0 ) {
+ if( ( ret = mbedtls_pk_setup( ctx, pk_info ) ) != 0 )
+ {
mbedtls_pem_free( &pem );
return( ret );
}
