]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
ui/gtk: Fix GTK assertion failure introduced with clipboard fixes
authorJindřich Makovička <makovick@gmail.com>
Fri, 1 May 2026 08:10:38 +0000 (10:10 +0200)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Sat, 9 May 2026 06:20:52 +0000 (10:20 +0400)
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 <makovick@gmail.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260501-clipboard-assert-fix-v1-1-e549243e4583@gmail.com>

ui/gtk-clipboard.c

index 463ed4e905b17b894500fc789f906b7e9afb1781..ea9444be70ff3240c88bfa1bc493b47a7c88e694 100644 (file)
@@ -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;
         }