From c1eb2cbd24544a2a0dc483892255e750ae455cce Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Tue, 13 Mar 2018 17:21:40 +0900 Subject: [PATCH] Fix memory leak - Variable 'remote_name' going out of scope leaks the storage it points to. - Variable 'uuids' going out of scope leaks the storage it points to. Change-Id: Ifcdaf562bbee01fecfa8dbb81ec741f4af5ab4f4 Signed-off-by: Wootak Jung --- common/src/libraries/bt-callback.c | 3 +++ common/src/ui/bt-main-view.c | 10 +++++++--- packaging/ug-bluetooth-efl.spec | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/common/src/libraries/bt-callback.c b/common/src/libraries/bt-callback.c index 3b84bf5..16d2c25 100644 --- a/common/src/libraries/bt-callback.c +++ b/common/src/libraries/bt-callback.c @@ -533,11 +533,13 @@ void _bt_cb_new_le_device_found(int result, bt_adapter_le_device_scan_result_inf dev = _bt_main_create_searched_le_device_item((void *)info); if (NULL == dev) { BT_ERR("Create new device item failed"); + g_free(remote_name); return; } if (_bt_main_add_searched_device(ugd, dev) == NULL) { BT_ERR("Fail to add the searched device"); + g_free(remote_name); return; } @@ -545,6 +547,7 @@ void _bt_cb_new_le_device_found(int result, bt_adapter_le_device_scan_result_inf eina_list_append(ugd->searched_device, dev); } + g_free(remote_name); FN_END; } diff --git a/common/src/ui/bt-main-view.c b/common/src/ui/bt-main-view.c index 56b5139..af35aef 100644 --- a/common/src/ui/bt-main-view.c +++ b/common/src/ui/bt-main-view.c @@ -2149,7 +2149,7 @@ bt_dev_t *_bt_main_create_searched_le_device_item(void *data) return NULL; } - if (strlen(remote_name) == 0) + if (!remote_name || strlen(remote_name) == 0) return NULL; /* only HOG Device will be shown in searched list */ @@ -2159,13 +2159,16 @@ bt_dev_t *_bt_main_create_searched_le_device_item(void *data) BT_DBG("UUID[%d] = %s", i + 1, uuids[i]); if (g_strcmp0(HOGP_SERVICE_UUID, uuids[i]) == 0) is_hog++; - + g_free(uuids[i]); } + g_free(uuids); } else BT_ERR("Fail to get LE service uuids"); - if (!is_hog) + if (!is_hog) { + g_free(remote_name); return NULL; + } dev = calloc(1, sizeof(bt_dev_t)); retv_if(dev == NULL, NULL); @@ -2186,6 +2189,7 @@ bt_dev_t *_bt_main_create_searched_le_device_item(void *data) dev->bd_addr[1], dev->bd_addr[2], dev->bd_addr[3], dev->bd_addr[4], dev->bd_addr[5]); + g_free(remote_name); FN_END; return dev; } diff --git a/packaging/ug-bluetooth-efl.spec b/packaging/ug-bluetooth-efl.spec index 04f93fc..ba6fd94 100644 --- a/packaging/ug-bluetooth-efl.spec +++ b/packaging/ug-bluetooth-efl.spec @@ -8,7 +8,7 @@ Name: ug-bluetooth-efl Summary: UI gadget about the bluetooth -Version: 0.5.3 +Version: 0.5.4 Release: 1 Group: App/Network License: Flora-1.1 -- 2.7.4