Fix memory leak (2) 52/253752/4 accepted/tizen/unified/20210305.141715 submit/tizen/20210304.062232
authorCheoleun Moon <chleun.moon@samsung.com>
Wed, 17 Feb 2021 06:34:54 +0000 (15:34 +0900)
committerCheoleun Moon <chleun.moon@samsung.com>
Thu, 4 Mar 2021 05:58:47 +0000 (14:58 +0900)
Change-Id: I142823aa716ae9226eb679449d7f878393c03b72

packaging/capi-network-wifi-manager.spec
src/network_dbus.c
src/network_interface.c
src/network_signal.c
src/wifi_internal.c

index 02aa421..7c98854 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          capi-network-wifi-manager
 Summary:       Network Wi-Fi library in TIZEN C API
-Version:       1.3.5
+Version:       1.3.6
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
index 9184881..572fd13 100755 (executable)
@@ -303,6 +303,8 @@ static void __net_open_connection_reply(GObject *source_object, GAsyncResult *re
        open_info = &request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION];
        wps_info = &request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS];
 
+       memset(&prof_info, 0, sizeof(net_profile_info_s));
+
        if (open_info->flag == TRUE) {
                g_strlcpy(event_data->ProfileName, open_info->ProfileName,
                                NET_PROFILE_NAME_LEN_MAX + 1);
@@ -363,6 +365,12 @@ static void __net_open_connection_reply(GObject *source_object, GAsyncResult *re
        if (network_info->event_callback)
                network_info->event_callback(event_data, network_info->user_data);
 
+       if (prof_info.vsie_list)
+               g_slist_free_full(prof_info.vsie_list, g_free);
+
+       if (prof_info.bssid_list)
+               g_slist_free_full(prof_info.bssid_list, g_free);
+
        g_free(event_data);
 
        __NETWORK_FUNC_EXIT__;
index 91e0d84..7ea71ae 100755 (executable)
@@ -3012,6 +3012,7 @@ int net_delete_profile(network_info_s *network_info, const char* profile_name)
                return NET_ERR_INVALID_PARAM; //LCOV_EXCL_LINE
        }
 
+       memset(&prof_info, 0, sizeof(net_profile_info_s));
        Error = __net_get_profile_info(network_info, profile_name, &prof_info);
        if (Error != NET_ERR_NONE) {
                WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
@@ -3028,6 +3029,13 @@ int net_delete_profile(network_info_s *network_info, const char* profile_name)
                        &wifi_prof_name,
                        prof_info.security_info.sec_mode,
                        prof_info.passpoint);
+
+       if (prof_info.vsie_list)
+               g_slist_free_full(prof_info.vsie_list, g_free);
+
+       if (prof_info.bssid_list)
+               g_slist_free_full(prof_info.bssid_list, g_free);
+
        if (Error != NET_ERR_NONE) {
                WIFI_LOG(WIFI_ERROR, //LCOV_EXCL_LINE
                                "Failed to delete service(profile). Error [%s]",
index 3d3a239..0c387a8 100755 (executable)
@@ -100,8 +100,8 @@ static int __net_handle_wifi_power_rsp(network_info_s *network_info,
 
        g_variant_get(param, "(s)", &interface_name);
        if (g_strcmp0(interface_name, network_info->interface_name) != 0) {
-               __NETWORK_FUNC_EXIT__;
                g_free(interface_name);
+               __NETWORK_FUNC_EXIT__;
                return NET_ERR_NONE;
        }
        g_free(interface_name);
@@ -916,12 +916,16 @@ static int __net_handle_scan_changed(network_info_s *network_info, GVariant *par
        g_variant_get(param, "(sv)", &interface_name, &var);
 
        if (g_strcmp0(interface_name, network_info->interface_name) != 0) {
+               g_free(interface_name);
+               g_variant_unref(var);
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_NONE;
        }
 
        event_data = g_try_malloc0(sizeof(net_event_info_s));
        if (event_data == NULL) {
+               g_free(interface_name);
+               g_variant_unref(var);
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_OUT_OF_MEMORY;
        }
@@ -940,6 +944,7 @@ static int __net_handle_scan_changed(network_info_s *network_info, GVariant *par
 
        g_free(event_data);
 
+       g_free(interface_name);
        g_variant_unref(var);
 
        WIFI_LOG(WIFI_INFO, "Exit Function");
@@ -957,13 +962,17 @@ static int __net_handle_scan_done(network_info_s *network_info, GVariant *param)
 
        g_variant_get(param, "(sv)", &interface_name, &value);
 
-       if (g_strcmp0(interface_name, network_info->interface_name) != 0)
+       if (g_strcmp0(interface_name, network_info->interface_name) != 0) {
+               g_free(interface_name);
+               g_variant_unref(value);
                return NET_ERR_NONE;
+       }
 
        last_scan_type = g_variant_get_int32(value);
        WIFI_LOG(WIFI_INFO, "%s last scan type: %d (0:full,1:specific,2:multi)",
                interface_name, last_scan_type);
 
+       g_free(interface_name);
        g_variant_unref(value);
 
        /* Check if any scan request is pending, if scan request is pending then
index ec3bc57..d29a5cf 100755 (executable)
@@ -1590,6 +1590,13 @@ void config_free(gpointer data)
                g_free(h->eap_config->subject_match);
                g_free(h->eap_config);
        }
+       if (h->ip_info) {
+               g_free(h->ip_info->ip_address);
+               g_free(h->ip_info->subnet_mask);
+               g_free(h->ip_info->gateway_address);
+               for (int i = 0; i < h->ip_info->dns_count; ++i)
+                       g_free(h->ip_info->dns_address[i]);
+       }
        g_free(h);
 }
 
@@ -3083,6 +3090,7 @@ int _wifi_load_configurations(wifi_manager_h wifi)
        int i;
        wifi_manager_handle_s *wifi_handle = wifi;
        GSList *config_ids = NULL;
+       GSList *head_config_ids = NULL;
 
        __clear_config_list(&(wifi_handle->config_iterator));
 
@@ -3097,6 +3105,7 @@ int _wifi_load_configurations(wifi_manager_h wifi)
                return WIFI_MANAGER_ERROR_NONE; //LCOV_EXCL_LINE
        }
 
+       head_config_ids = config_ids;
        while (config_ids) {
                wifi_config_s *h;
                gchar *id = config_ids->data;
@@ -3161,8 +3170,7 @@ int _wifi_load_configurations(wifi_manager_h wifi)
                config_ids = config_ids->next;
        }
 
-       config_ids = g_slist_nth(config_ids, 0);
-       g_slist_free_full(config_ids, g_free);
+       g_slist_free_full(head_config_ids, g_free);
 
        return WIFI_MANAGER_ERROR_NONE;
 }