Fix some coverity 96/244296/2
authorhyunuk.tak <hyunuk.tak@samsung.com>
Thu, 17 Sep 2020 04:44:05 +0000 (13:44 +0900)
committerhyunuk.tak <hyunuk.tak@samsung.com>
Fri, 18 Sep 2020 04:20:25 +0000 (13:20 +0900)
FORWARD_NULL, REVERSE_INULL, RESOURCE_LEAK

Change-Id: I000aabec4e012889734c6f5f17f077023dcb0092
Signed-off-by: hyunuk.tak <hyunuk.tak@samsung.com>
src/signal-handler.c
src/utils/setting.c
src/utils/util.c

index bd7004b..495881b 100755 (executable)
@@ -375,15 +375,18 @@ static void _technology_signal_cb(GDBusConnection *conn,
                        } else if (g_strcmp0(key, "Powered") == 0) {
                                bvalue = g_variant_get_boolean(var);
                                DBG("Powered [%d]", bvalue);
-                               wifi_state_update_power_state(svalue, bvalue);
+                               if (svalue)
+                                       wifi_state_update_power_state(svalue, bvalue);
                        } else if (g_strcmp0(key, "Connected") == 0) {
                                bvalue = g_variant_get_boolean(var);
                                DBG("Connected [%d]", bvalue);
-                               wifi_state_set_connected(svalue, bvalue);
-                               if (bvalue == TRUE)
-                                       wifi_state_set_technology_state(svalue, NETCONFIG_WIFI_TECH_CONNECTED);
-                               else
-                                       wifi_state_set_technology_state(svalue, NETCONFIG_WIFI_TECH_POWERED);
+                               if (svalue) {
+                                       wifi_state_set_connected(svalue, bvalue);
+                                       if (bvalue == TRUE)
+                                               wifi_state_set_technology_state(svalue, NETCONFIG_WIFI_TECH_CONNECTED);
+                                       else
+                                               wifi_state_set_technology_state(svalue, NETCONFIG_WIFI_TECH_POWERED);
+                               }
                        }
                }
                g_variant_iter_free(iter);
index a278a01..8412379 100755 (executable)
@@ -92,6 +92,7 @@ static void __setting_set_string_list(GKeyFile *keyfile, netconfig_setting_type_
                                netconfig_setting_data[type].key, NULL);
                }
 
+               g_strfreev(string_list);
                g_string_free(string_str, TRUE);
        }
 }
index e139ab8..495e2ac 100755 (executable)
@@ -158,12 +158,16 @@ void netconfig_keyfile_save(GKeyFile *keyfile, const char *pathname)
        gchar *needle = NULL, *directory = NULL;
 
        directory = g_strdup(pathname);
-       needle = g_strrstr(directory, "/");
+       if (directory == NULL) {
+               ERR("directory is NULL");
+               return;
+       }
 
+       needle = g_strrstr(directory, "/");
        if (needle != NULL)
                *needle = '\0';
 
-       if (directory == NULL || (*directory) == '\0') {
+       if ((*directory) == '\0') {
                g_free(directory);
                ERR("directory is NULL");
                return;