From ac39c334d979063b5324d56e9a7236f4b62f0f21 Mon Sep 17 00:00:00 2001 From: "hyunuk.tak" Date: Thu, 17 Sep 2020 13:04:18 +0900 Subject: [PATCH] Fix memory leak Change-Id: I390587f1110e8e93febad8ba0ba23d81e39d22b5 Signed-off-by: hyunuk.tak --- src/network_dbus.c | 9 ++++++--- src/network_interface.c | 2 +- src/network_signal.c | 3 ++- src/wifi_internal.c | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/network_dbus.c b/src/network_dbus.c index 77275d1..8b7e051 100755 --- a/src/network_dbus.c +++ b/src/network_dbus.c @@ -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__; } diff --git a/src/network_interface.c b/src/network_interface.c index 98c5864..a679d9a 100755 --- a/src/network_interface.c +++ b/src/network_interface.c @@ -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; } diff --git a/src/network_signal.c b/src/network_signal.c index 70a2be5..3a3c6d6 100755 --- a/src/network_signal.c +++ b/src/network_signal.c @@ -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; } diff --git a/src/wifi_internal.c b/src/wifi_internal.c index 6010566..5763521 100755 --- a/src/wifi_internal.c +++ b/src/wifi_internal.c @@ -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; -- 2.7.4