Free vconf_get_str using free() instead of g_free() 59/124059/2
authorAbhishek Sansanwal <abhishek.s94@samsung.com>
Mon, 10 Apr 2017 05:24:54 +0000 (10:54 +0530)
committerAbhishek Sansanwal <abhishek.s94@samsung.com>
Tue, 11 Apr 2017 03:50:57 +0000 (09:20 +0530)
Signed-off-by: Abhishek Sansanwal <abhishek.s94@samsung.com>
Change-Id: I3c55cf7d470346f0a4901826cdcfabb0d7abcafc

src/network-state.c
src/signal-handler.c
src/wifi-config.c
src/wifi-power.c
src/wifi.c

index 15e0cc9..00c8cc2 100755 (executable)
@@ -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);
 
index f06136a..81a657e 100755 (executable)
@@ -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);
                }
        }
 }
index aa2ab05..9d14b2a 100755 (executable)
@@ -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];
index 9cb9af8..c34bccf 100755 (executable)
@@ -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);
 
 }
index 889387f..ad7d098 100755 (executable)
@@ -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);
        }
 }