chiark / gitweb /
networkd: fix use-after-free
authorTom Gundersen <teg@jklm.no>
Mon, 31 Mar 2014 08:01:59 +0000 (10:01 +0200)
committerTom Gundersen <teg@jklm.no>
Mon, 31 Mar 2014 08:01:59 +0000 (10:01 +0200)
Free networks before links (the reverse of creation order).

src/network/networkd-manager.c

index b2cb0fa..ddbdabb 100644 (file)
@@ -145,13 +145,13 @@ void manager_free(Manager *m) {
         sd_event_source_unref(m->sigint_event_source);
         sd_event_unref(m->event);
 
         sd_event_source_unref(m->sigint_event_source);
         sd_event_unref(m->event);
 
-        while ((network = m->networks))
-                network_free(network);
-
         while ((link = hashmap_first(m->links)))
                 link_free(link);
         hashmap_free(m->links);
 
         while ((link = hashmap_first(m->links)))
                 link_free(link);
         hashmap_free(m->links);
 
+        while ((network = m->networks))
+                network_free(network);
+
         while ((netdev = hashmap_first(m->netdevs)))
                 netdev_free(netdev);
         hashmap_free(m->netdevs);
         while ((netdev = hashmap_first(m->netdevs)))
                 netdev_free(netdev);
         hashmap_free(m->netdevs);