]> git.sur5r.net Git - i3/i3/commitdiff
Fix memory leaks in modes and bar bindings. 2001/head
authorIngo Bürk <ingo.buerk@tngtech.com>
Fri, 30 Oct 2015 17:10:41 +0000 (13:10 -0400)
committerIngo Bürk <ingo.buerk@tngtech.com>
Sun, 1 Nov 2015 21:35:17 +0000 (16:35 -0500)
src/config.c

index 89c1d09ab058bc2e940cf82324874f05d3703ba0..f146b906a4c9e5a042128d0601f5864a8df481d3 100644 (file)
@@ -75,20 +75,20 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
         ungrab_all_keys(conn);
 
         struct Mode *mode;
-        Binding *bind;
         while (!SLIST_EMPTY(&modes)) {
             mode = SLIST_FIRST(&modes);
             FREE(mode->name);
 
             /* Clear the old binding list */
-            bindings = mode->bindings;
-            while (!TAILQ_EMPTY(bindings)) {
-                bind = TAILQ_FIRST(bindings);
-                TAILQ_REMOVE(bindings, bind, bindings);
+            while (!TAILQ_EMPTY(mode->bindings)) {
+                Binding *bind = TAILQ_FIRST(mode->bindings);
+                TAILQ_REMOVE(mode->bindings, bind, bindings);
                 binding_free(bind);
             }
-            FREE(bindings);
+            FREE(mode->bindings);
+
             SLIST_REMOVE(&modes, mode, Mode, modes);
+            FREE(mode);
         }
 
         struct Assignment *assign;
@@ -110,12 +110,21 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
             FREE(barconfig->id);
             for (int c = 0; c < barconfig->num_outputs; c++)
                 free(barconfig->outputs[c]);
+
+            while (!TAILQ_EMPTY(&(barconfig->bar_bindings))) {
+                struct Barbinding *binding = TAILQ_FIRST(&(barconfig->bar_bindings));
+                FREE(binding->command);
+                TAILQ_REMOVE(&(barconfig->bar_bindings), binding, bindings);
+                FREE(binding);
+            }
+
             while (!TAILQ_EMPTY(&(barconfig->tray_outputs))) {
                 struct tray_output_t *tray_output = TAILQ_FIRST(&(barconfig->tray_outputs));
                 FREE(tray_output->output);
                 TAILQ_REMOVE(&(barconfig->tray_outputs), tray_output, tray_outputs);
                 FREE(tray_output);
             }
+
             FREE(barconfig->outputs);
             FREE(barconfig->socket_path);
             FREE(barconfig->status_command);