From: Deokhyun Kim Date: Tue, 17 Sep 2019 01:43:35 +0000 (+0900) Subject: Fix mem leak X-Git-Tag: accepted/tizen/unified/20190919.065320^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F43%2F213943%2F2;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git Fix mem leak Change-Id: I3d25d486b5b9ee95fb1b3d3e0ba51f9ea004ea76 Signed-off-by: Deokhyun Kim --- diff --git a/bt-api/bt-common.c b/bt-api/bt-common.c index e64a804..9d573f0 100644 --- a/bt-api/bt-common.c +++ b/bt-api/bt-common.c @@ -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;