Fix memory leak 34/172334/2 accepted/tizen/unified/20180314.141414 accepted/tizen/unified/20180411.065605 submit/tizen/20180314.004906 submit/tizen/20180410.230750
authorWootak Jung <wootak.jung@samsung.com>
Tue, 13 Mar 2018 08:21:40 +0000 (17:21 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Tue, 13 Mar 2018 08:32:07 +0000 (08:32 +0000)
- 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 <wootak.jung@samsung.com>
common/src/libraries/bt-callback.c
common/src/ui/bt-main-view.c
packaging/ug-bluetooth-efl.spec

index 3b84bf5..16d2c25 100644 (file)
@@ -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;
 }
 
index 56b5139..af35aef 100644 (file)
@@ -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;
 }
index 04f93fc..ba6fd94 100644 (file)
@@ -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