From 6a5cbfa95e530230147364ff6358381d2829569f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 29 Sep 2024 03:02:27 +0200 Subject: [PATCH] Don't crash in selection "owner changed" if saved mimetype is null We may end up in a situation when there is no new owner but there is saved clipboard without saved MIME type. In this case calling meta_selection_source_memory_new() fails and, worse, dereferencing null error pointer when logging this failure results in a crash. Avoid this by not calling it in this case because it is perfectly possible for saved clipboard to be set to a non-null pointer in transfer_cb, yet for the saved MIME type to be null if the data is not available in any of the supported MIME types. --- src/core/meta-clipboard-manager.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/core/meta-clipboard-manager.c b/src/core/meta-clipboard-manager.c index 8121f26fa15..f9aed93dcc5 100644 --- a/src/core/meta-clipboard-manager.c +++ b/src/core/meta-clipboard-manager.c @@ -147,13 +147,11 @@ owner_changed_cb (MetaSelection *selection, (GAsyncReadyCallback) transfer_cb, output); } - else if (!new_owner && display->saved_clipboard) + else if (!new_owner && display->saved_clipboard && display->saved_clipboard_mimetype) { g_autoptr (GError) error = NULL; g_autoptr (MetaSelectionSource) new_source = NULL; - g_assert (display->saved_clipboard_mimetype != NULL); - /* Old owner is gone, time to take over */ new_source = meta_selection_source_memory_new (display->saved_clipboard_mimetype, display->saved_clipboard, -- GitLab