Fix memory leak in psa_copy_key

This commit is contained in:
Gilles Peskine 2019-01-23 10:55:43 +01:00
parent f603c718c9
commit 122d002912

View File

@ -1228,16 +1228,15 @@ static psa_status_t psa_copy_key_material( const psa_key_slot_t *source,
psa_get_key_bits( source ) );
buffer = mbedtls_calloc( 1, buffer_size );
if( buffer == NULL )
{
status = PSA_ERROR_INSUFFICIENT_MEMORY;
goto exit;
}
return( PSA_ERROR_INSUFFICIENT_MEMORY );
status = psa_internal_export_key( source, buffer, buffer_size, &length, 0 );
if( status != PSA_SUCCESS )
goto exit;
status = psa_import_key( target, source->type, buffer, length );
exit:
mbedtls_platform_zeroize( buffer, buffer_size );
mbedtls_free( buffer );
return( status );
}