Only zeroize buffer if the buffer length is non-zero
@@ -1235,6 +1235,7 @@ static psa_status_t psa_copy_key_material( const psa_key_slot_t *source,
status = psa_import_key( target, source->type, buffer, length );
exit:
+ if( buffer_size != 0 )
mbedtls_platform_zeroize( buffer, buffer_size );
mbedtls_free( buffer );
return( status );
