Skip to content

Commit f535577

Browse files
Fix memory leak in psa_copy_key
1 parent 86304e1 commit f535577

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
@@ -1160,16 +1160,15 @@ static psa_status_t psa_copy_key_material( const psa_key_slot_t *source,
11601160
psa_get_key_bits( source ) );
11611161
buffer = mbedtls_calloc( 1, buffer_size );
11621162
if( buffer == NULL )
1163-
{
1164-
status = PSA_ERROR_INSUFFICIENT_MEMORY;
1165-
goto exit;
1166-
}
1163+
return( PSA_ERROR_INSUFFICIENT_MEMORY );
11671164
status = psa_internal_export_key( source, buffer, buffer_size, &length, 0 );
11681165
if( status != PSA_SUCCESS )
11691166
goto exit;
11701167
status = psa_import_key( target, source->type, buffer, length );
11711168

11721169
exit:
1170+
mbedtls_platform_zeroize( buffer, buffer_size );
1171+
mbedtls_free( buffer );
11731172
return( status );
11741173
}
11751174

0 commit comments

Comments
 (0)