bt_service: map: Fix proxy leak and double unref 27/143627/2
authorSyam Sidhardhan <s.syam@samsung.com>
Mon, 31 Jul 2017 09:07:36 +0000 (14:37 +0530)
committerSyam Sidhardhan <s.syam@samsung.com>
Thu, 10 Aug 2017 17:02:14 +0000 (22:32 +0530)
We need to unref the session proxy. We need to avoid double unref

(error) Memory leak: session_proxy
(error) Memory pointed to by 'value' is freed twice

Change-Id: I94324727ecdc1f586eacb8f785206098b2a648ad
Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
bt-service/bt-service-map-client.c

index d6bc887..3ea576d 100644 (file)
@@ -115,6 +115,9 @@ int _bt_create_session_sync(const char* address, char** session_id)
 
        GVariant *value = g_dbus_proxy_call_sync(session_proxy, "CreateSession", param,
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+
+       g_object_unref(session_proxy);
+
        if (err != NULL) {
                BT_ERR("Could not create session: %s\n", err->message);
                g_error_free(err);
@@ -162,6 +165,9 @@ int _bt_destroy_session_sync(const char* session_id)
 
        g_dbus_proxy_call_sync(session_proxy, "RemoveSession", param,
                        G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
+
+       g_object_unref(session_proxy);
+
        if (err != NULL) {
                BT_ERR("Could not remove session: %s\n", err->message);
                g_error_free(err);
@@ -579,10 +585,8 @@ static void __bt_push_message_cb(GDBusProxy *proxy,
                g_clear_error(&error);
        }
 
-       if (value) {
+       if (value)
                g_variant_get(value, "(oa{sv})", &transfer_object_path, &iter);
-               g_variant_unref(value);
-       }
 
        BT_DBG("transfer object path: [%s]", transfer_object_path);
 
@@ -686,10 +690,8 @@ static void __bt_get_message_cb(GDBusProxy *proxy,
                g_clear_error(&error);
        }
 
-       if (value) {
+       if (value)
                g_variant_get(value, "(oa{sv})", &transfer_object_path, &iter);
-               g_variant_unref(value);
-       }
 
        BT_DBG("transfer object path: [%s]", transfer_object_path);