Fix memory leaks in modes and bar bindings.

This commit is contained in:
Ingo Bürk 2015-10-30 13:10:41 -04:00
parent bc250b26a0
commit 5b9fb51b37
1 changed files with 15 additions and 6 deletions

View File

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