From c25daf55a3f87084d8816b469670404d6ee57549 Mon Sep 17 00:00:00 2001 From: Abhishek Sansanwal Date: Mon, 10 Apr 2017 10:54:54 +0530 Subject: [PATCH] Free vconf_get_str using free() instead of g_free() Signed-off-by: Abhishek Sansanwal Change-Id: I3c55cf7d470346f0a4901826cdcfabb0d7abcafc --- src/network-state.c | 15 ++++++++++++--- src/signal-handler.c | 4 ++-- src/wifi-config.c | 5 +++-- src/wifi-power.c | 4 ++-- src/wifi.c | 2 +- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/network-state.c b/src/network-state.c index 15e0cc9..00c8cc2 100755 --- a/src/network-state.c +++ b/src/network-state.c @@ -494,6 +494,12 @@ static void __netconfig_update_default_connection_info(void) if (!netconfig_is_cellular_internet_profile(profile)) { DBG("connection is not a internet profile - stop to update the cellular state"); + if (old_ip) + free(old_ip); + if (old_ip6) + free(old_ip6); + if (old_proxy) + free(old_proxy); return; } @@ -521,7 +527,8 @@ static void __netconfig_update_default_connection_info(void) else if (old_ip != NULL && strlen(old_ip) > 0) netconfig_set_vconf_str(VCONFKEY_NETWORK_IP, ""); } - g_free(old_ip); + if (old_ip) + free(old_ip); if (g_strcmp0(old_ip6, ip_addr6) != 0 || old_ip6 == NULL) { if (ip_addr6 != NULL) @@ -529,7 +536,8 @@ static void __netconfig_update_default_connection_info(void) else if (old_ip6 != NULL && strlen(old_ip6) > 0) netconfig_set_vconf_str(VCONFKEY_NETWORK_IP6, ""); } - g_free(old_ip6); + if (old_ip6) + free(old_ip6); if (g_strcmp0(old_proxy, proxy_addr) != 0) { if (proxy_addr == NULL) @@ -537,7 +545,8 @@ static void __netconfig_update_default_connection_info(void) else netconfig_set_vconf_str(VCONFKEY_NETWORK_PROXY, proxy_addr); } - g_free(old_proxy); + if (old_proxy) + free(old_proxy); netconfig_set_vconf_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 1); diff --git a/src/signal-handler.c b/src/signal-handler.c index f06136a..81a657e 100755 --- a/src/signal-handler.c +++ b/src/signal-handler.c @@ -116,7 +116,7 @@ static void __netconfig_extract_ipv4_signal_data(GVariant *dictionary, const gch else vconf_set_str(VCONFKEY_NETWORK_IP, value); } - g_free(old_ip); + free(old_ip); } } } @@ -141,7 +141,7 @@ static void __netconfig_extract_ipv6_signal_data(GVariant *dictionary, const gch else vconf_set_str(VCONFKEY_NETWORK_IP6, value); } - g_free(old_ip6); + free(old_ip6); } } } diff --git a/src/wifi-config.c b/src/wifi-config.c index aa2ab05..9d14b2a 100755 --- a/src/wifi-config.c +++ b/src/wifi-config.c @@ -122,13 +122,14 @@ static gboolean __get_mac_address(gchar **mac_address) fclose(fp); return FALSE; } - tmp_mac = (char *)g_try_malloc0(WIFI_MAC_ADD_LENGTH + 1); + tmp_mac = (gchar *)malloc(WIFI_MAC_ADD_LENGTH + 1); if (tmp_mac == NULL) { ERR("malloc() failed"); *mac_address = NULL; fclose(fp); return FALSE; } + memset(tmp_mac, 0, WIFI_MAC_ADD_LENGTH + 1); g_strlcpy(tmp_mac, buf, WIFI_MAC_ADD_LENGTH + 1); fclose(fp); } else { @@ -140,7 +141,7 @@ static gboolean __get_mac_address(gchar **mac_address) } } tmp = g_ascii_strdown(tmp_mac, (gssize)strlen(tmp_mac)); - g_free(tmp_mac); + free(tmp_mac); while (tmp && tmp[i]) { if (tmp[i] != ':') mac[j++] = tmp[i]; diff --git a/src/wifi-power.c b/src/wifi-power.c index 9cb9af8..c34bccf 100755 --- a/src/wifi-power.c +++ b/src/wifi-power.c @@ -1045,7 +1045,7 @@ void __netconfig_set_ether_macaddr() if (__netconfig_get_random_mac(rand_mac_add, ETH_MAC_ADDR_SIZE) == -1) { ERR("Could not generate the Random Mac address"); - g_free(mac_addr); + free(mac_addr); return; } @@ -1073,6 +1073,6 @@ void __netconfig_set_ether_macaddr() if (rv < 0) ERR("Unable to execute system command"); - g_free(mac_addr); + free(mac_addr); } diff --git a/src/wifi.c b/src/wifi.c index 889387f..ad7d098 100755 --- a/src/wifi.c +++ b/src/wifi.c @@ -68,7 +68,7 @@ static void _set_wifi_mac_address(void) if (mac_addr != NULL) { if (strlen(mac_addr) == 0) netconfig_set_mac_address_from_file(); - g_free(mac_addr); + free(mac_addr); } } -- 2.7.4