From e7f147618062401e8d16ea2a953354d34329bcf3 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 9 Jan 2016 13:46:49 +0100 Subject: [PATCH] reload: fix memory leak --- include/config.h | 2 +- src/config.c | 4 ++++ src/config_directives.c | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/config.h b/include/config.h index f4b1efd5..d5465c3f 100644 --- a/include/config.h +++ b/include/config.h @@ -94,7 +94,7 @@ struct Config { i3Font font; char *ipc_socket_path; - const char *restart_state_path; + char *restart_state_path; layout_t default_layout; int container_stack_limit; diff --git a/src/config.c b/src/config.c index ef632128..a1111463 100644 --- a/src/config.c +++ b/src/config.c @@ -169,6 +169,10 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath, /* Get rid of the current font */ free_font(); + + free(config.ipc_socket_path); + free(config.restart_state_path); + free(config.fake_outputs); } SLIST_INIT(&modes); diff --git a/src/config_directives.c b/src/config_directives.c index 85cea4cf..0d4b3d31 100644 --- a/src/config_directives.c +++ b/src/config_directives.c @@ -261,6 +261,7 @@ CFGFUN(workspace_back_and_forth, const char *value) { } CFGFUN(fake_outputs, const char *outputs) { + free(config.fake_outputs); config.fake_outputs = sstrdup(outputs); } @@ -313,10 +314,12 @@ CFGFUN(workspace, const char *workspace, const char *output) { } CFGFUN(ipc_socket, const char *path) { + free(config.ipc_socket_path); config.ipc_socket_path = sstrdup(path); } CFGFUN(restart_state, const char *path) { + free(config.restart_state_path); config.restart_state_path = sstrdup(path); } -- 2.39.5