Skip to content

Commit cad49af

Browse files
Fix memory leak in psa_copy_key
1 parent ee4b119 commit cad49af

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
@@ -1173,16 +1173,15 @@ static psa_status_t psa_copy_key_material( const psa_key_slot_t *source,
11731173
psa_get_key_bits( source ) );
11741174
buffer = mbedtls_calloc( 1, buffer_size );
11751175
if( buffer == NULL )
1176-
{
1177-
status = PSA_ERROR_INSUFFICIENT_MEMORY;
1178-
goto exit;
1179-
}
1176+
return( PSA_ERROR_INSUFFICIENT_MEMORY );
11801177
status = psa_internal_export_key( source, buffer, buffer_size, &length, 0 );
11811178
if( status != PSA_SUCCESS )
11821179
goto exit;
11831180
status = psa_import_key( target, source->type, buffer, length );
11841181

11851182
exit:
1183+
mbedtls_platform_zeroize( buffer, buffer_size );
1184+
mbedtls_free( buffer );
11861185
return( status );
11871186
}
11881187

0 commit comments

Comments
 (0)