Fix svace issue (WGID-212341)
[platform/core/connectivity/net-config.git] / src / signal-handler.c
index 81a657e..385bd98 100755 (executable)
@@ -18,6 +18,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <vconf.h>
 #include <vconf-keys.h>
@@ -111,10 +112,10 @@ static void __netconfig_extract_ipv4_signal_data(GVariant *dictionary, const gch
 
                        DBG("Old IPv4.Address [%s] Received new IPv4.Address [%s]", old_ip, value);
                        if (g_strcmp0(old_ip, value) != 0) {
-                               if (value == NULL && strlen(old_ip) > 0)
-                                       vconf_set_str(VCONFKEY_NETWORK_IP, "");
-                               else
+                               if (value != NULL)
                                        vconf_set_str(VCONFKEY_NETWORK_IP, value);
+                               else if (old_ip != NULL && strlen(old_ip) > 0)
+                                       vconf_set_str(VCONFKEY_NETWORK_IP, "");
                        }
                        free(old_ip);
                }
@@ -136,10 +137,10 @@ static void __netconfig_extract_ipv6_signal_data(GVariant *dictionary, const gch
 
                        DBG("Old IPv6.Address [%s] Received new IPv6.Address [%s]", old_ip6, value);
                        if (g_strcmp0(old_ip6, value) != 0) {
-                               if (value == NULL && strlen(old_ip6) > 0)
-                                       vconf_set_str(VCONFKEY_NETWORK_IP6, "");
-                               else
+                               if (value != NULL)
                                        vconf_set_str(VCONFKEY_NETWORK_IP6, value);
+                               else if (old_ip6 != NULL && strlen(old_ip6) > 0)
+                                       vconf_set_str(VCONFKEY_NETWORK_IP6, "");
                        }
                        free(old_ip6);
                }