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().
---
 plugins/wifi.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index bac1fc6..4ddc133 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -965,8 +965,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;
                }
@@ -975,8 +974,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;
                }
@@ -984,10 +982,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.8.4.474.g128a96c

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

Reply via email to