]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: fix incorrect free of GVariant in our GLib mock functions
authorPavel Hrdina <phrdina@redhat.com>
Fri, 2 Oct 2020 10:11:45 +0000 (12:11 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Fri, 2 Oct 2020 10:43:15 +0000 (12:43 +0200)
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 <crobinso@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/networkxml2firewalltest.c
tests/virfirewalltest.c
tests/virpolkittest.c
tests/virsystemdtest.c

index e0244f508ef6d3d31805940b9ad83dea8e739727..3496445f0dc780ccf1df5133c885659dbafb8b2e 100644 (file)
@@ -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);
+    }
 
     VIR_MOCK_REAL_INIT(g_dbus_connection_call_sync);
 
index 607638e9d0e0b2d9ef9ad278730014887d69007a..646b999d96e0c040fe9ed133fa96e013af56b0fb 100644 (file)
@@ -79,6 +79,9 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync,
     GVariant *reply = NULL;
     g_autoptr(GVariant) params = parameters;
 
+    if (params)
+        g_variant_ref_sink(params);
+
     VIR_MOCK_REAL_INIT(g_dbus_connection_call_sync);
 
     if (STREQ(bus_name, "org.freedesktop.DBus") &&
index 011d83a506eab98a08e3cf90ab8734c015b527e9..b7cbe28466c9a30448b6bf91e2b9d8b7b1ab1c2f 100644 (file)
@@ -52,6 +52,9 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync,
     GVariant *reply = NULL;
     g_autoptr(GVariant) params = parameters;
 
+    if (params)
+        g_variant_ref_sink(params);
+
     VIR_MOCK_REAL_INIT(g_dbus_connection_call_sync);
 
     if (STREQ(bus_name, "org.freedesktop.PolicyKit1") &&
index c1411d7c05d1e1a84dcc497e1c39955493cc0680..bd0ca51140cb39a1423400b69da47ae7cb43eae0 100644 (file)
@@ -54,8 +54,10 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync,
 {
     GVariant *reply = NULL;
 
-    if (parameters)
+    if (parameters) {
+        g_variant_ref_sink(parameters);
         g_variant_unref(parameters);
+    }
 
     VIR_MOCK_REAL_INIT(g_dbus_connection_call_sync);