From 881ae10993c6f11a05cad6f92a2f07c5f06494e0 Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Tue, 13 Mar 2018 11:50:46 +0900 Subject: Fix resource leak CID-110047 Change-Id: I4dc702929473a004ca5025ddeb1d5703f5b34c94 --- src/net-popup.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/net-popup.c b/src/net-popup.c index 9020dd9..9d64598 100755 --- a/src/net-popup.c +++ b/src/net-popup.c @@ -229,35 +229,49 @@ void __net_popup_send_data_usage_msg(const char *app_id, ret = stc_initialize(&stc); if (ret != STC_ERROR_NONE) { - log_print(NET_POPUP, "Failed to get operation ret= %d\n", ret); - return; + log_print(NET_POPUP, "Failed to initialize ret= %d\n", ret); + goto DONE; } ret = stc_restriction_rule_create(stc, &rule); if (ret != STC_ERROR_NONE) { log_print(NET_POPUP, "Failed to create restriction rule ret= %d\n", ret); - return; + goto DONE; } ret = stc_restriction_rule_set_app_id(rule, app_id); if (ret != STC_ERROR_NONE) { log_print(NET_POPUP, "Failed to set application ID ret= %d\n", ret); - return; + goto DONE; } ret = stc_restriction_rule_set_iface_type(rule, iftype[0] - '0'); if (ret != STC_ERROR_NONE) { log_print(NET_POPUP, "Failed to set interface type ret= %d\n", ret); - return; + goto DONE; } ret = stc_unset_restriction(stc, rule); if (ret != STC_ERROR_NONE) { log_print(NET_POPUP, "Failed to unset restriction ret= %d\n", ret); - return; + goto DONE; } log_print(NET_POPUP, "Success to unset restriction\n"); + +DONE: + if (rule) { + ret = stc_restriction_rule_destroy(rule); + if (ret != STC_ERROR_NONE) + log_print(NET_POPUP, "Failed to destroy restriction rule ret= %d\n", ret); + } + + if (stc) { + ret = stc_deinitialize(stc); + if (ret != STC_ERROR_NONE) + log_print(NET_POPUP, "Failed to deinitialize ret= %d\n", ret); + } + return; } @@ -1833,6 +1847,9 @@ error: if (noti != NULL) notification_free(noti); + + if (service_handle) + app_control_destroy(service_handle); } static void __net_popup_del_found_ap_noti(void) -- cgit v1.2.3