{"id":2231704,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2231704/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260501-clipboard-assert-fix-v1-1-e549243e4583@gmail.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260501-clipboard-assert-fix-v1-1-e549243e4583@gmail.com>","date":"2026-05-01T08:10:38","name":"ui/gtk: Fix GTK assertion failure introduced with clipboard fixes","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e2e9d614e1a30383810593a5c79fef97ca7f620c","submitter":{"id":4408,"url":"http://patchwork.ozlabs.org/api/1.1/people/4408/?format=json","name":"Jindřich Makovička","email":"makovick@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260501-clipboard-assert-fix-v1-1-e549243e4583@gmail.com/mbox/","series":[{"id":502433,"url":"http://patchwork.ozlabs.org/api/1.1/series/502433/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=502433","date":"2026-05-01T08:10:38","name":"ui/gtk: Fix GTK assertion failure introduced with clipboard fixes","version":1,"mbox":"http://patchwork.ozlabs.org/series/502433/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2231704/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2231704/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=KKaXmBhb;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g6NzS69n6z1y04\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 18:11:31 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wIixZ-0007bM-AN; Fri, 01 May 2026 04:10:54 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <makovick@gmail.com>)\n id 1wIixV-0007bA-Ro\n for qemu-devel@nongnu.org; Fri, 01 May 2026 04:10:49 -0400","from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <makovick@gmail.com>)\n id 1wIixT-0002n2-DC\n for qemu-devel@nongnu.org; Fri, 01 May 2026 04:10:49 -0400","by mail-wm1-x32c.google.com with SMTP id\n 5b1f17b1804b1-488b0046078so14209145e9.1\n for <qemu-devel@nongnu.org>; Fri, 01 May 2026 01:10:45 -0700 (PDT)","from [192.168.0.10] ([2a03:ab00:1000:1b60:331a:b316:78f6:effc])\n by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-48a8fe92b3asm9151955e9.4.2026.05.01.01.10.43\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 01 May 2026 01:10:43 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1777623044; x=1778227844; darn=nongnu.org;\n h=cc:to:message-id:content-transfer-encoding:mime-version:subject\n :date:from:from:to:cc:subject:date:message-id:reply-to;\n bh=OJUhC55K9A0xZ0ORpMZG0kGY/2Fw7VzTRIPuHLeV+Xw=;\n b=KKaXmBhbqleAC13a0ZE9iRB9F0t/KxD+ZzlIquRyHwSqmzmycTL/keHaSeLEd8bwcu\n h9AnCXPeslYR8rcdN04TkNgvvKe5KH0o5h9m5S8TxPvzx4xl7PCH1d42V9ONwttA2p8H\n 7ydfQKitUNnm8+R6gVufvVQRJh6W8lF176gVXLna+/b0coyKfz6oHtB5tucCetzszm/j\n i2WKEp0RkL8LGYB6NG+dmZv6aJ6eBOw9NFJWZ4egOYwMnZ8ZypVqP1niaXR/7srGlK+L\n hnGdfMFd5iPaLsJmBrqIHw2LAtqlQwlE83vD7v92tkN5S67AYvrzyWtMSSZ+F0WbUdzj\n sWMA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777623044; x=1778227844;\n h=cc:to:message-id:content-transfer-encoding:mime-version:subject\n :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=OJUhC55K9A0xZ0ORpMZG0kGY/2Fw7VzTRIPuHLeV+Xw=;\n b=e1Zfg77HN0YCrA3GM5nSUTk+Tmp+u3vqL+368+wiedREhWZ6C08uJJmodSv8RG9bCa\n JEMkNy2dFX9o6Tgp8bLGGIJKFqsQ1BmW2rCk1YNuHGksi08z8Q7Aea4oFhi4vyhpzYPV\n KDujnpZGyJfUYRApv3g4Y1uLMHxctU69iWxXgKwo1Lphuyy8ku6fGFEjQVccupEC071R\n xIesVAJj/Glhy+aj3LVXrJeRt3ASRL1pK888O1r2SXMbX5cTBVvORL6oqSlUNmywr+fM\n WF7SbDzIe0CW8J+QRhTjL8v2Lyl0Y+UBmuN/nhOHcs0l2TGHesAltUPa1a7P+4H6i0SL\n YGAA==","X-Gm-Message-State":"AOJu0Yw/klQrsOmrI0dpxuladrscWe+eFF0xAKMN4ZrgG00kcCtYpax3\n RtyRehke3aJuwIWNbJ1UNlXPc+3VPmroO+St7OdQyiNslRQIWVzV49iPwy2pTdT2","X-Gm-Gg":"AeBDietGt7Mn/jJPp+WBf5fbOuqkZioqGmGEAm6WW/urxS8n4jxqH5En0n83kE7GCLW\n Lu2kY8D5hqjWnm6Od7cbV08sVwQ2cWHKkdZ3Zmo8h/T3KU6xxMSmukeGbicI4QaAomhCUSbDH45\n /cbx2w6nVlm572Y0Ga83X6EWn4MIrqO5DmuZp4KTS9BNePbwZ31hHpcL0aGITgqVz9fS9KOBcBn\n gAvtw7KDAtHpTBwF4M18O6VeNbz1rFVE9cyeYvXqZAmfpaDVRm8n34DGQV0qUuZGvOWB+t4GGrp\n TdOldzqQSBDCxLapGn9NWJxTcCQds0tfV4iVZ4fFLbp9jYQlu8gmth7osnWZL7iJEDGqqGwWU5A\n z9BRvhICp96w2T4dtqzY/81XsWIozFurXG4T28IEh/vvVcTYYhUTX3PZm1PqJGlbCrzYEeAcAOT\n RshyoJvN/KrBDCuWR6JHWnjQvB62KKW3L3Oy0e96A=","X-Received":"by 2002:a05:600c:859a:b0:489:1ba8:5be9 with SMTP id\n 5b1f17b1804b1-48a8ebaed76mr20781565e9.29.1777623043669;\n Fri, 01 May 2026 01:10:43 -0700 (PDT)","From":"=?utf-8?q?Jind=C5=99ich_Makovi=C4=8Dka?= <makovick@gmail.com>","Date":"Fri, 01 May 2026 10:10:38 +0200","Subject":"[PATCH] ui/gtk: Fix GTK assertion failure introduced with\n clipboard fixes","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20260501-clipboard-assert-fix-v1-1-e549243e4583@gmail.com>","X-B4-Tracking":"v=1; b=H4sIAP1f9GkC/x2MSQqAMAwAvyI5G6gFq/gV8dAl1YCotCJC6d8NH\n mdgpkCmxJRhagokejjzeQh0bQN+s8dKyEEYtNJG9apDv/PlTpsC2iztjZFf9F67OJpBk7Mg6ZV\n I9L+dl1o/5KY382YAAAA=","X-Change-ID":"20260501-clipboard-assert-fix-cc2bf8672eba","To":"qemu-devel@nongnu.org","Cc":"=?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>,\n  Jindrich Makovicka <makovick@gmail.com>","X-Mailer":"b4 0.14.3","Received-SPF":"pass client-ip=2a00:1450:4864:20::32c;\n envelope-from=makovick@gmail.com; helo=mail-wm1-x32c.google.com","X-Spam_score_int":"-20","X-Spam_score":"-2.1","X-Spam_bar":"--","X-Spam_report":"(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"gtk_clipboard_request_targets actually returns n_targets == -1\nwhen targets ==  NULL instead of zero. This result in failed assertion\nwithin GTK:\n\nqemu: Gtk: gtk_targets_include_text:\nassertion 'targets != NULL || n_targets == 0' failed\n\nExtend the check to require non-null targets and positive n_targets.\n\nSigned-off-by: Jindrich Makovicka <makovick@gmail.com>\n---\nHi,\n\nwith my latest gtk-clipboard changes, I introduced the following GTK\nassertion failures due to unexpected n_targets value returned to\ncallback from gtk_clipboard_request_targets\n\nqemu: Gtk: gtk_targets_include_text:\nassertion 'targets != NULL || n_targets == 0' failed\n\nfrom\n\ngboolean \ngtk_targets_include_text (GdkAtom *targets,\n                          gint     n_targets)\n{\n  gint i;\n  gboolean result = FALSE;\n\n  g_return_val_if_fail (targets != NULL || n_targets == 0, FALSE);\n\n  /* Keep in sync with gtk_target_list_add_text_targets()\n   */\n \n  init_atoms ();\n \n  for (i = 0; i < n_targets; i++)\n...\n\nGTK actually returns -1 instead of zero when there are no targets,\ntriggering the assert. The following patch extends the check to\nnon-null targets and positive n_targets to be on the safe side.\n---\n ui/gtk-clipboard.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\n\n---\nbase-commit: 3d626609ccae61a2e552bccd59c7a0931bab8261\nchange-id: 20260501-clipboard-assert-fix-cc2bf8672eba\n\nBest regards,","diff":"diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c\nindex 463ed4e905..ea9444be70 100644\n--- a/ui/gtk-clipboard.c\n+++ b/ui/gtk-clipboard.c\n@@ -175,7 +175,7 @@ static void gd_clipboard_owner_change_targets_received_callback(\n {\n     QemuClipboardInfo *info = (QemuClipboardInfo *)data;\n \n-    if (n_targets) {\n+    if (targets && n_targets > 0) {\n         if (gtk_targets_include_text(targets, n_targets)) {\n             info->types[QEMU_CLIPBOARD_TYPE_TEXT].available = true;\n         }\n","prefixes":[]}