Fix mem leak 43/213943/2 accepted/tizen/unified/20190919.065320 submit/tizen/20190919.003432
authorDeokhyun Kim <dukan.kim@samsung.com>
Tue, 17 Sep 2019 01:43:35 +0000 (10:43 +0900)
committerDeokhyun Kim <dukan.kim@samsung.com>
Wed, 18 Sep 2019 08:52:24 +0000 (17:52 +0900)
Change-Id: I3d25d486b5b9ee95fb1b3d3e0ba51f9ea004ea76
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
bt-api/bt-common.c

index e64a804..9d573f0 100644 (file)
@@ -750,7 +750,6 @@ gboolean _bt_utf8_validate(char *name)
        return TRUE;
 }
 
-
 static GDBusProxy *profile_gproxy;
 static int latest_id = -1;
 #define BT_RFCOMM_ID_MAX 245
@@ -1422,6 +1421,8 @@ int _bt_connect_profile(char *address, char *uuid, void *cb,
                        DBUS_TIMEOUT, NULL,
                        (GAsyncReadyCallback)cb,
                        func_data);
+       if (cb == NULL)
+               g_object_unref(proxy);
        BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
@@ -1467,6 +1468,8 @@ int _bt_discover_services(char *address, char *uuid, void *cb,
                        DBUS_TIMEOUT, NULL,
                        (GAsyncReadyCallback)cb,
                        func_data);
+       if (cb == NULL)
+               g_object_unref(proxy);
        BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
@@ -1687,6 +1690,8 @@ int _bt_disconnect_profile(char *address, char *uuid, void *cb,
                        DBUS_TIMEOUT, NULL,
                        (GAsyncReadyCallback)cb,
                        func_data);
+       if (cb == NULL)
+               g_object_unref(proxy);
        BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
@@ -1711,6 +1716,7 @@ int _bt_disconnect_ext_profile(char *address, char *path)
                        g_variant_new("(o)", path),
                        G_DBUS_CALL_FLAGS_NONE,
                        DBUS_TIMEOUT, NULL, NULL, NULL);
+       g_object_unref(proxy);
        BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
@@ -2432,7 +2438,6 @@ BT_EXPORT_API int bluetooth_unregister_callback(void)
 {
        int ret;
 
-
        ret = _bt_deinit_event_handler();
        if (ret != BLUETOOTH_ERROR_NONE)
                BT_ERR("Fail to deinit the event handler");
@@ -2445,6 +2450,11 @@ BT_EXPORT_API int bluetooth_unregister_callback(void)
 
        _bt_gdbus_deinit_proxys();
 
+       if (profile_gproxy) {
+               g_object_unref(profile_gproxy);
+               profile_gproxy = NULL;
+       }
+
        if (system_private_conn) {
                g_object_unref(system_private_conn);
                system_private_conn = NULL;