From 960a41fbfd8a4969e4f7da32352f0038b103efad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jind=C5=99ich=20Makovi=C4=8Dka?= Date: Fri, 1 May 2026 10:10:38 +0200 Subject: [PATCH] ui/gtk: Fix GTK assertion failure introduced with clipboard fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gtk_clipboard_request_targets actually returns n_targets == -1 when targets == NULL instead of zero. This result in failed assertion within GTK: qemu: Gtk: gtk_targets_include_text: assertion 'targets != NULL || n_targets == 0' failed Extend the check to require non-null targets and positive n_targets. Signed-off-by: Jindrich Makovicka Reviewed-by: Marc-André Lureau Message-ID: <20260501-clipboard-assert-fix-v1-1-e549243e4583@gmail.com> --- ui/gtk-clipboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index 463ed4e905..ea9444be70 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -175,7 +175,7 @@ static void gd_clipboard_owner_change_targets_received_callback( { QemuClipboardInfo *info = (QemuClipboardInfo *)data; - if (n_targets) { + if (targets && n_targets > 0) { if (gtk_targets_include_text(targets, n_targets)) { info->types[QEMU_CLIPBOARD_TYPE_TEXT].available = true; }