Don't segfault if dbus is not running.
[dhcpcd-ui] / src / dhcpcd-gtk / main.c
index b4cf28f274d1ce6f557739eb2038a1739a52964a..f68cb1633b3d9e72e1a2a0362a634f7b3d16534b 100644 (file)
@@ -251,8 +251,8 @@ status_cb(DHCPCD_CONNECTION *con, const char *status, _unused void *data)
                dhcpcd_prefs_abort();
                while (wi_scans) {
                        w = wi_scans->next;
-                       dhcpcd_wi_scans_free(w->scans);
-                       free(wi_scans);
+                       dhcpcd_wi_scans_free(wi_scans->scans);
+                       g_free(wi_scans);
                        wi_scans = w;
                }
        } else {
@@ -311,7 +311,7 @@ scan_cb(DHCPCD_CONNECTION *con, DHCPCD_IF *i, _unused void *data)
                        notify(msg, txt, "network-wireless");
                        g_free(txt);
                }
-               g_free(w->scans);
+               dhcpcd_wi_scans_free(w->scans);
        }
        w->scans = scans;
 }
@@ -411,8 +411,10 @@ main(int argc, char *argv[])
 
        g_message(_("Connecting ..."));
        con = dhcpcd_open(&error);
-       if (con ==  NULL)
+       if (con ==  NULL) {
                g_critical("libdhcpcd: %s", error);
+               exit(EXIT_FAILURE);
+       }
 
        gtk_status_icon_set_tooltip(status_icon, _("Triggering dhcpcd ..."));
        online = false;