Fix resource leaks
These potential leaks were flagged by the Coverity static analyzer. Signed-off-by: Leonid Rozenboim <leonid.rozenboim@oracle.com>
This commit is contained in:
parent
4d7af2aee0
commit
116f50cd96
2 changed files with 7 additions and 1 deletions
|
@ -1456,8 +1456,10 @@ int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx,
|
||||||
if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == NULL )
|
if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == NULL )
|
||||||
return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG );
|
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 );
|
return( ret );
|
||||||
|
}
|
||||||
|
|
||||||
if ( ( ret = pk_get_rsapubkey( &p, p + pem.buflen, mbedtls_pk_rsa( *ctx ) ) ) != 0 )
|
if ( ( ret = pk_get_rsapubkey( &p, p + pem.buflen, mbedtls_pk_rsa( *ctx ) ) ) != 0 )
|
||||||
mbedtls_pk_free( ctx );
|
mbedtls_pk_free( ctx );
|
||||||
|
|
|
@ -312,7 +312,11 @@ exit:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( session_serialized != NULL )
|
if( session_serialized != NULL )
|
||||||
|
{
|
||||||
mbedtls_platform_zeroize( session_serialized, session_serialized_len );
|
mbedtls_platform_zeroize( session_serialized, session_serialized_len );
|
||||||
|
mbedtls_free(session_serialized);
|
||||||
|
session_serialized = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue