Skip to content

Commit

Permalink
Add pem_free() to other error paths in pk_parse_public_key()
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Elliott <[email protected]>
  • Loading branch information
paul-elliott-arm authored and Andrzej Kurek committed Jul 5, 2022
1 parent 763ee3c commit b39b499
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions library/pkparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1462,10 +1462,14 @@ int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx,
if( ret == 0 )
{
p = pem.buf;
if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == NULL )
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 );
}
Expand Down

0 comments on commit b39b499

Please sign in to comment.