Fix memory leak 25/224925/3 accepted/tizen/unified/20200219.130126 submit/tizen/20200216.235341 submit/tizen/20200219.053014
authorSemun Lee <semun.lee@samsung.com>
Fri, 14 Feb 2020 06:11:10 +0000 (15:11 +0900)
committerSemun Lee <semun.lee@samsung.com>
Fri, 14 Feb 2020 08:25:46 +0000 (17:25 +0900)
Change-Id: I0a72c7a7a3dcce8f1115910142c7e377d4c0bdf8
Signed-off-by: Semun Lee <semun.lee@samsung.com>
plugin/bm-bt-plugin/src/bm_bt_plugin.c

index cf376d3..79d5dda 100644 (file)
@@ -130,8 +130,7 @@ int get_feature_data(bm_data_h *handle, bm_plugin_data_type_e type)
        _I("connectedTime: %u", bluetooth_record->connectedTime);
 
        /* Getting app data */
-       GSList *app_list = NULL, *l = NULL;
-       app_list = bluetooth_record->atm_list;
+       GSList *l = NULL;
        bt_battery_app_info_s *app_info = NULL;
 
        for (l = battery_data.atm_list; l != NULL; l = g_slist_next(l)) {
@@ -149,6 +148,7 @@ int get_feature_data(bm_data_h *handle, bm_plugin_data_type_e type)
                        _E("app_info is NULL");
                        free_app_list(bluetooth_record->atm_list);
                        free(bluetooth_record);
+                       free(app_record);
                        return BM_PLUGIN_ERROR_NO_DATA;
                }
 
@@ -159,7 +159,8 @@ int get_feature_data(bm_data_h *handle, bm_plugin_data_type_e type)
                app_record->tx = app_info->tx_bytes;
 
                /* Fill the app_record with the values of the app_time_map_st2 */
-               app_list = g_slist_append(app_list, app_record);
+               bluetooth_record->atm_list =
+                       g_slist_append(bluetooth_record->atm_list, app_record);
        }
 
        /*Append BT data to head node as per design doc*/