Fix memory leak 94/244294/2
authorhyunuk.tak <hyunuk.tak@samsung.com>
Thu, 17 Sep 2020 04:04:18 +0000 (13:04 +0900)
committerhyunuk.tak <hyunuk.tak@samsung.com>
Thu, 17 Sep 2020 04:49:39 +0000 (13:49 +0900)
Change-Id: I390587f1110e8e93febad8ba0ba23d81e39d22b5
Signed-off-by: hyunuk.tak <hyunuk.tak@samsung.com>
src/network_dbus.c
src/network_interface.c
src/network_signal.c
src/wifi_internal.c

index 77275d1..8b7e051 100755 (executable)
@@ -412,6 +412,8 @@ static void __net_scan_reply(GObject *source_object, GAsyncResult *res, gpointer
 
                g_free(event_data);
 
+               __NETWORK_FUNC_EXIT__;
+               return;
        } else if (Error == NET_ERR_IN_PROGRESS) {
                /* should retry scan after receiving scan result */
                if (request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
@@ -452,6 +454,7 @@ static void __net_scan_reply(GObject *source_object, GAsyncResult *res, gpointer
        } else
                WIFI_LOG(WIFI_INFO, "Scan Request success");
 
+       g_free(event_data);
        __NETWORK_FUNC_EXIT__;
 }
 
@@ -568,6 +571,7 @@ static void __net_wifi_power_reply(GObject *source_object, GAsyncResult *res, gp
                        }
                }
        } else {
+               g_free(event_data);
                __NETWORK_FUNC_EXIT__;
                return;
        }
@@ -576,7 +580,6 @@ static void __net_wifi_power_reply(GObject *source_object, GAsyncResult *res, gp
                network_info->event_callback(event_data, network_info->user_data);
 
        g_free(event_data);
-
        __NETWORK_FUNC_EXIT__;
 }
 
@@ -2002,7 +2005,6 @@ static void __net_specific_scan_request_reply(GObject *source_object, GAsyncResu
                                network_info->event_callback(event_data, network_info->user_data);
 
                        g_free(event_data);
-
                        __NETWORK_FUNC_EXIT__;
                        return;
                }
@@ -2010,6 +2012,7 @@ static void __net_specific_scan_request_reply(GObject *source_object, GAsyncResu
        } else
                WIFI_LOG(WIFI_INFO, "Specific Scan Request success");
 
+       g_free(event_data);
        __NETWORK_FUNC_EXIT__;
 }
 
@@ -2580,6 +2583,7 @@ static void __net_wps_connect_wifi_reply(GObject *source_object,
                g_variant_unref(dbus_result);
 
        if (Error == NET_ERR_NONE) {
+               g_free(event_data);
                __NETWORK_FUNC_EXIT__;
                return;
        }
@@ -2598,7 +2602,6 @@ static void __net_wps_connect_wifi_reply(GObject *source_object,
                network_info->event_callback(event_data, network_info->user_data);
 
        g_free(event_data);
-
        __NETWORK_FUNC_EXIT__;
 }
 
index 98c5864..a679d9a 100755 (executable)
@@ -2836,7 +2836,7 @@ int net_register_client_ext(network_info_s **network_info,
        for (list = interface_list; list; list = list->next) {
                const char *ifname = list->data;
                if (interface_name == NULL || !g_strcmp0(interface_name, ifname)) {
-                       g_strlcpy(net_info->interface_name, ifname, NET_WLAN_IF_NAME_LEN + 1);
+                       g_strlcpy(net_info->interface_name, ifname, NET_WLAN_IF_NAME_LEN);
                        WIFI_LOG(WIFI_INFO, "Set interface name [%s]", ifname);
                        break;
                }
index 70a2be5..3a3c6d6 100755 (executable)
@@ -649,7 +649,7 @@ static void __net_handle_failure_ind(network_info_s *network_info,
                event_data->Event = NET_EVENT_CLOSE_RSP;
        } else {
                __net_handle_state_ind(network_info, profile_name, NET_STATE_TYPE_FAILURE);
-
+               g_free(event_data);
                __NETWORK_FUNC_EXIT__;
                return;
        }
@@ -1315,6 +1315,7 @@ static int __net_handle_wifi_connect_fail_event(network_info_s *network_info,
                WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_WIFI_WPS_RSP");
        } else {
                WIFI_LOG(WIFI_WARN, "WiFi Connection flag not set");
+               g_free(event_data);
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_NONE;
        }
index 6010566..5763521 100755 (executable)
@@ -1526,7 +1526,7 @@ int _wifi_init(wifi_manager_h wifi, const char *ifname)
        }
 
        g_strlcpy(wifi_handle->interface_name,
-               wifi_handle->network_info->interface_name, NET_WLAN_IF_NAME_LEN + 1);
+               wifi_handle->network_info->interface_name, NET_WLAN_IF_NAME_LEN);
        wifi_handle->network_info->wifi_handle = wifi_handle;
 
        return WIFI_MANAGER_ERROR_NONE;