From: Semun Lee Date: Fri, 14 Feb 2020 06:11:10 +0000 (+0900) Subject: Fix memory leak X-Git-Tag: accepted/tizen/unified/20200219.130126^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F25%2F224925%2F3;p=platform%2Fcore%2Fsystem%2Fbatterymonitor-plugins.git Fix memory leak Change-Id: I0a72c7a7a3dcce8f1115910142c7e377d4c0bdf8 Signed-off-by: Semun Lee --- diff --git a/plugin/bm-bt-plugin/src/bm_bt_plugin.c b/plugin/bm-bt-plugin/src/bm_bt_plugin.c index cf376d3..79d5dda 100644 --- a/plugin/bm-bt-plugin/src/bm_bt_plugin.c +++ b/plugin/bm-bt-plugin/src/bm_bt_plugin.c @@ -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*/