clipboard-manager: Make sure we always have mimetype

The precondition checks in meta_selection_source_memory_new can return
NULL if the mimetype is NULL but callers expect the error to be set when
NULL is returned.

Let's just make sure we never call it with a NULL mimetype.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3678>
This commit is contained in:
Sebastian Wick 2024-03-28 14:55:49 +01:00 committed by Marge Bot
parent 5dfed8a431
commit ce32d2b77a

View File

@ -126,7 +126,7 @@ owner_changed_cb (MetaSelection *selection,
}
}
if (best_idx < 0)
if (!best)
{
g_list_free_full (mimetypes, g_free);
return;
@ -149,6 +149,8 @@ owner_changed_cb (MetaSelection *selection,
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,