Skip to content

Commit 122d002

Browse files
Fix memory leak in psa_copy_key
1 parent f603c71 commit 122d002

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

library/psa_crypto.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,16 +1228,15 @@ static psa_status_t psa_copy_key_material( const psa_key_slot_t *source,
12281228
psa_get_key_bits( source ) );
12291229
buffer = mbedtls_calloc( 1, buffer_size );
12301230
if( buffer == NULL )
1231-
{
1232-
status = PSA_ERROR_INSUFFICIENT_MEMORY;
1233-
goto exit;
1234-
}
1231+
return( PSA_ERROR_INSUFFICIENT_MEMORY );
12351232
status = psa_internal_export_key( source, buffer, buffer_size, &length, 0 );
12361233
if( status != PSA_SUCCESS )
12371234
goto exit;
12381235
status = psa_import_key( target, source->type, buffer, length );
12391236

12401237
exit:
1238+
mbedtls_platform_zeroize( buffer, buffer_size );
1239+
mbedtls_free( buffer );
12411240
return( status );
12421241
}
12431242

0 commit comments

Comments
 (0)