@samitouri / QOSamiQemu / commits / 960a41fbfd

ui/gtk: Fix GTK assertion failure introduced with clipboard fixes

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>

Jindřich Makovička committed May 1, 2026 at 10:10 UTC 960a41fbfd8a4969e4f7da32352f0038b103efad
1 file changed +1 -1
ui/gtk-clipboard.c
+1 -1
@@ -175,7 +175,7 @@ static void gd_clipboard_owner_change_targets_received_callback(
175 {
176 QemuClipboardInfo *info = (QemuClipboardInfo *)data;
177
178 - if (n_targets) {
178 + if (targets && n_targets > 0) {
179 if (gtk_targets_include_text(targets, n_targets)) {
180 info->types[QEMU_CLIPBOARD_TYPE_TEXT].available = true;
181 }