Fix usage of GVariant in "g_dbus_proxy_call_sync" 63/265963/3
authorIlho Kim <ilho159.kim@samsung.com>
Tue, 2 Nov 2021 10:16:03 +0000 (19:16 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Wed, 3 Nov 2021 00:27:40 +0000 (09:27 +0900)
The function "g_dbus_proxy_call_sync" consumes the floating GVariant parameter
So from the second loop, the variable is consumed, causing incorrect memory access
This patch changes GVariant variable from floating reference
to full reference using g_variant_ref_sink

Change-Id: I11f97ee20f72a7540413e60d921950fd0a5cdd90
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
plugin/app2sd/lib/app2sd_client_interface.c

index 739ef05..efbf557 100644 (file)
@@ -69,10 +69,15 @@ static int __app2sd_call_server_method(const gchar *method_name,
        GError *error = NULL;
        GVariant *value = NULL;
 
+       if (param)
+               g_variant_ref_sink(param);
+
        /* get gdbus connection */
        ret = app2sd_gdbus_shared_connection(&conn);
        if (ret) {
                _E("app2sd error : dbus connection error");
+               if (param)
+                       g_variant_unref(param);
                return ret;
        }
 
@@ -119,6 +124,8 @@ static int __app2sd_call_server_method(const gchar *method_name,
 
        if (conn)
                g_object_unref(conn);
+       if (param)
+               g_variant_unref(param);
 
        return ret;
 }