From nobody Thu May 2 00:59:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601634976; cv=none; d=zohomail.com; s=zohoarc; b=JGL8oUE7FGwM/MeM/uy3gXwphCa2v1h5MW/CNlHlx0UL52sjeNdguFO+8eLOx5oacQGYEucPRAK066x/APpnSXEenXbdnUyI0HLzU1FBDDw89wF79Hyknyw+DEic5Axi7ZvbK6fUCTfXiQkRHNjZszNOQHdTQYiTupaW3KX0B8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601634976; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=O/xy4Q9GB5JTL6ljEymb7FaLQI857Y/0I0vG+2PlYDg=; b=LnuL6g3cBM6u/X9QSA4A/2cXCXg8y0bQqWDi7WitRAsfs7BFv5q9b0hs9EKf4FdNH7fpbkqJnPaZ72s1J58Cv7WEOCFmauVVUqpyOETiw5rt605t/aY5j0iHH2O3yvgSmYIVelZZhXdO2ezqDj9mx3MeFVtmragnkUZvUPrdUYQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601634976156946.2830748144914; Fri, 2 Oct 2020 03:36:16 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-322-H0dawLuKMEmymgFV_yTx3g-1; Fri, 02 Oct 2020 06:36:13 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E0147108E1A2; Fri, 2 Oct 2020 10:36:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B4E7D55770; Fri, 2 Oct 2020 10:36:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 72D221826D2D; Fri, 2 Oct 2020 10:36:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 092Aa6cE027653 for ; Fri, 2 Oct 2020 06:36:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id F1F4C60C47; Fri, 2 Oct 2020 10:36:05 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7020460CD1 for ; Fri, 2 Oct 2020 10:36:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601634974; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=O/xy4Q9GB5JTL6ljEymb7FaLQI857Y/0I0vG+2PlYDg=; b=EyJlxe3MyJyGQRChxlYevuufcvKJ1aBqvNji5K2H2b7jeZaogehnM1CzW6jA3qUJ7aUpB6 tf/wvAv32FI27PDwjmvyxwMvBrCVb/fP5jFDAorS9Wi3Zw+sUXnQgxqlciLJMOTOOZ5T+9 UAEq9tZu7Ew84uyuDu9XP6xOUDd66M8= X-MC-Unique: H0dawLuKMEmymgFV_yTx3g-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH] tests: fix incorrect free of GVariant in our GLib mock functions Date: Fri, 2 Oct 2020 12:36:01 +0200 Message-Id: <83ce63cc64c6a7692be6c21cf7ef6c98f8c9c7cf.1601634953.git.phrdina@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" GLib implementation of g_dbus_connection_call_sync() calls g_variant_ref_sink() on the passed @parameters to make sure they have proper reference. If the original reference is floating the g_dbus_connection_call_sync() consumes it, but if it's normal reference it will just add another one. Our mock functions were only freeing the @parameters which is incorrect and doesn't reflect how the real implementation works. Reported-by: Cole Robinson Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik --- tests/networkxml2firewalltest.c | 4 +++- tests/virfirewalltest.c | 3 +++ tests/virpolkittest.c | 3 +++ tests/virsystemdtest.c | 4 +++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltes= t.c index e0244f508e..3496445f0d 100644 --- a/tests/networkxml2firewalltest.c +++ b/tests/networkxml2firewalltest.c @@ -60,8 +60,10 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync, GCancellable *, cancellable, GError **, error) { - if (parameters) + if (parameters) { + g_variant_ref_sink(parameters); g_variant_unref(parameters); + } =20 VIR_MOCK_REAL_INIT(g_dbus_connection_call_sync); =20 diff --git a/tests/virfirewalltest.c b/tests/virfirewalltest.c index 607638e9d0..646b999d96 100644 --- a/tests/virfirewalltest.c +++ b/tests/virfirewalltest.c @@ -79,6 +79,9 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync, GVariant *reply =3D NULL; g_autoptr(GVariant) params =3D parameters; =20 + if (params) + g_variant_ref_sink(params); + VIR_MOCK_REAL_INIT(g_dbus_connection_call_sync); =20 if (STREQ(bus_name, "org.freedesktop.DBus") && diff --git a/tests/virpolkittest.c b/tests/virpolkittest.c index 011d83a506..b7cbe28466 100644 --- a/tests/virpolkittest.c +++ b/tests/virpolkittest.c @@ -52,6 +52,9 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync, GVariant *reply =3D NULL; g_autoptr(GVariant) params =3D parameters; =20 + if (params) + g_variant_ref_sink(params); + VIR_MOCK_REAL_INIT(g_dbus_connection_call_sync); =20 if (STREQ(bus_name, "org.freedesktop.PolicyKit1") && diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c index c1411d7c05..bd0ca51140 100644 --- a/tests/virsystemdtest.c +++ b/tests/virsystemdtest.c @@ -54,8 +54,10 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync, { GVariant *reply =3D NULL; =20 - if (parameters) + if (parameters) { + g_variant_ref_sink(parameters); g_variant_unref(parameters); + } =20 VIR_MOCK_REAL_INIT(g_dbus_connection_call_sync); =20 --=20 2.26.2