Fix memory leak 83/225983/1
authorSemun Lee <semun.lee@samsung.com>
Fri, 14 Feb 2020 06:11:10 +0000 (15:11 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 26 Feb 2020 04:36:26 +0000 (13:36 +0900)
Change-Id: I0a72c7a7a3dcce8f1115910142c7e377d4c0bdf8
Signed-off-by: Semun Lee <semun.lee@samsung.com>
plugin/bm-bt-plugin/src/bm_bt_plugin.c

index cf376d388b16a7ff67def625c041a79688127fbc..79d5dda576563cedbcb366c3143e86d540f1c3d4 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*/