gdk/wayland: Avoid invalid memory access on cancellation

The only way to have G_IO_ERROR_CANCELLED in the write callback
goes through having the array of pending writers already cleared.
It should not access the invalid AsyncWriteData and StoredSelection
in that case.
This commit is contained in:
Carlos Garnacho
2020-02-20 14:03:50 +01:00
parent 81ef7eb30b
commit 6893118510

View File

@ -734,13 +734,14 @@ async_write_data_cb (GObject *object,
res, &error);
if (error)
{
if (error->domain != G_IO_ERROR ||
error->code != G_IO_ERROR_CANCELLED)
g_warning ("Error writing selection data: %s", error->message);
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
{
g_warning ("Error writing selection data: %s", error->message);
g_ptr_array_remove_fast (write_data->stored_selection->pending_writes,
write_data);
}
g_error_free (error);
g_ptr_array_remove_fast (write_data->stored_selection->pending_writes,
write_data);
return;
}