From: Daniel Wagner <[email protected]>

When the Modified is missing in the keyfile we would just
go on use the unitialized variable.

While we are at it, also drop the unnessary checks for NULL
string before passing it to g_free().

Reported by coverity.
---
 plugins/wifi.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index b99e6f3..533d6df 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -960,8 +960,7 @@ static int get_latest_connections(int max_ssids,
                str = g_key_file_get_string(keyfile,
                                        services[i], "Favorite", NULL);
                if (!str || g_strcmp0(str, "true")) {
-                       if (str)
-                               g_free(str);
+                       g_free(str);
                        g_key_file_free(keyfile);
                        continue;
                }
@@ -970,8 +969,7 @@ static int get_latest_connections(int max_ssids,
                str = g_key_file_get_string(keyfile,
                                        services[i], "AutoConnect", NULL);
                if (!str || g_strcmp0(str, "true")) {
-                       if (str)
-                               g_free(str);
+                       g_free(str);
                        g_key_file_free(keyfile);
                        continue;
                }
@@ -979,10 +977,12 @@ static int get_latest_connections(int max_ssids,
 
                str = g_key_file_get_string(keyfile,
                                        services[i], "Modified", NULL);
-               if (str) {
-                       g_time_val_from_iso8601(str, &modified);
-                       g_free(str);
+               if (!str) {
+                       g_key_file_free(keyfile);
+                       continue;
                }
+               g_time_val_from_iso8601(str, &modified);
+               g_free(str);
 
                ssid = g_key_file_get_string(keyfile,
                                        services[i], "SSID", NULL);
-- 
1.7.10.207.g0bb2e

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to