render / rpms / libvirt

Forked from rpms/libvirt 7 months ago
Clone
452883
From 48622bb5637587a1cc24f7fdc8ab32cd89798a9d Mon Sep 17 00:00:00 2001
452883
Message-Id: <48622bb5637587a1cc24f7fdc8ab32cd89798a9d.1601670767.git.crobinso@redhat.com>
452883
From: Pavel Hrdina <phrdina@redhat.com>
452883
Date: Fri, 2 Oct 2020 12:11:45 +0200
452883
Subject: [PATCH] tests: fix incorrect free of GVariant in our GLib mock
452883
 functions
452883
452883
GLib implementation of g_dbus_connection_call_sync() calls
452883
g_variant_ref_sink() on the passed @parameters to make sure they have
452883
proper reference. If the original reference is floating the
452883
g_dbus_connection_call_sync() consumes it, but if it's normal reference
452883
it will just add another one.
452883
452883
Our mock functions were only freeing the @parameters which is incorrect
452883
and doesn't reflect how the real implementation works.
452883
452883
Reported-by: Cole Robinson <crobinso@redhat.com>
452883
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
452883
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
452883
Signed-off-by: Cole Robinson <crobinso@redhat.com>
452883
---
452883
 tests/networkxml2firewalltest.c | 4 +++-
452883
 tests/virfirewalltest.c         | 3 +++
452883
 tests/virpolkittest.c           | 3 +++
452883
 tests/virsystemdtest.c          | 4 +++-
452883
 4 files changed, 12 insertions(+), 2 deletions(-)
452883
452883
diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltest.c
452883
index e0244f508e..3496445f0d 100644
452883
--- a/tests/networkxml2firewalltest.c
452883
+++ b/tests/networkxml2firewalltest.c
452883
@@ -60,8 +60,10 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync,
452883
                        GCancellable *, cancellable,
452883
                        GError **, error)
452883
 {
452883
-    if (parameters)
452883
+    if (parameters) {
452883
+        g_variant_ref_sink(parameters);
452883
         g_variant_unref(parameters);
452883
+    }
452883
 
452883
     VIR_MOCK_REAL_INIT(g_dbus_connection_call_sync);
452883
 
452883
diff --git a/tests/virfirewalltest.c b/tests/virfirewalltest.c
452883
index 607638e9d0..646b999d96 100644
452883
--- a/tests/virfirewalltest.c
452883
+++ b/tests/virfirewalltest.c
452883
@@ -79,6 +79,9 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync,
452883
     GVariant *reply = NULL;
452883
     g_autoptr(GVariant) params = parameters;
452883
 
452883
+    if (params)
452883
+        g_variant_ref_sink(params);
452883
+
452883
     VIR_MOCK_REAL_INIT(g_dbus_connection_call_sync);
452883
 
452883
     if (STREQ(bus_name, "org.freedesktop.DBus") &&
452883
diff --git a/tests/virpolkittest.c b/tests/virpolkittest.c
452883
index 011d83a506..b7cbe28466 100644
452883
--- a/tests/virpolkittest.c
452883
+++ b/tests/virpolkittest.c
452883
@@ -52,6 +52,9 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync,
452883
     GVariant *reply = NULL;
452883
     g_autoptr(GVariant) params = parameters;
452883
 
452883
+    if (params)
452883
+        g_variant_ref_sink(params);
452883
+
452883
     VIR_MOCK_REAL_INIT(g_dbus_connection_call_sync);
452883
 
452883
     if (STREQ(bus_name, "org.freedesktop.PolicyKit1") &&
452883
diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c
452883
index c1411d7c05..bd0ca51140 100644
452883
--- a/tests/virsystemdtest.c
452883
+++ b/tests/virsystemdtest.c
452883
@@ -54,8 +54,10 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync,
452883
 {
452883
     GVariant *reply = NULL;
452883
 
452883
-    if (parameters)
452883
+    if (parameters) {
452883
+        g_variant_ref_sink(parameters);
452883
         g_variant_unref(parameters);
452883
+    }
452883
 
452883
     VIR_MOCK_REAL_INIT(g_dbus_connection_call_sync);
452883
 
452883
-- 
452883
2.28.0
452883