diff --git a/Userland/Services/SpiceAgent/SpiceAgent.cpp b/Userland/Services/SpiceAgent/SpiceAgent.cpp index 0d74286a5b..86e960e32f 100644 --- a/Userland/Services/SpiceAgent/SpiceAgent.cpp +++ b/Userland/Services/SpiceAgent/SpiceAgent.cpp @@ -132,11 +132,15 @@ void SpiceAgent::on_message_received() m_just_set_clip = true; if (type == ClipboardType::Text) { - auto anon_buffer_or_error = Core::AnonymousBuffer::create_with_size(data_buffer.size()); - VERIFY(!anon_buffer_or_error.is_error()); - auto anon_buffer = anon_buffer_or_error.release_value(); - memcpy(anon_buffer.data(), data_buffer.data(), data_buffer.size()); - m_clipboard_connection.async_set_clipboard_data(anon_buffer, "text/plain", {}); + if (data_buffer.is_empty()) { + m_clipboard_connection.async_set_clipboard_data({}, "text/plain", {}); + } else { + auto anon_buffer_or_error = Core::AnonymousBuffer::create_with_size(data_buffer.size()); + VERIFY(!anon_buffer_or_error.is_error()); + auto anon_buffer = anon_buffer_or_error.release_value(); + memcpy(anon_buffer.data(), data_buffer.data(), data_buffer.size()); + m_clipboard_connection.async_set_clipboard_data(anon_buffer, "text/plain", {}); + } return; } else { ErrorOr frame_or_error = Gfx::ImageFrameDescriptor {};