aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2016-04-29 14:08:43 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2016-04-29 14:08:43 -0400
commited8c67e2908f0370b8d665ebc09f75e784dafeac (patch)
tree1f10e0f9ed77b680ca1f5cf151df3e4b4c707817
parentMerge pull request #614 from neosilky/memleak (diff)
parentsway/config.c: Move the wordfree call before the if statement so it is always... (diff)
downloadsway-ed8c67e2908f0370b8d665ebc09f75e784dafeac.tar.gz
sway-ed8c67e2908f0370b8d665ebc09f75e784dafeac.tar.zst
sway-ed8c67e2908f0370b8d665ebc09f75e784dafeac.zip
Merge pull request #615 from neosilky/memleak
Cleaned up some un-free'd memory
-rw-r--r--common/stringop.c2
-rw-r--r--sway/config.c8
2 files changed, 7 insertions, 3 deletions
diff --git a/common/stringop.c b/common/stringop.c
index 61324458..432bee7f 100644
--- a/common/stringop.c
+++ b/common/stringop.c
@@ -144,7 +144,7 @@ char **split_args(const char *start, int *argc) {
144} 144}
145 145
146void free_argv(int argc, char **argv) { 146void free_argv(int argc, char **argv) {
147 while (--argc > 0) { 147 while (argc-- > 0) {
148 free(argv[argc]); 148 free(argv[argc]);
149 } 149 }
150 free(argv); 150 free(argv);
diff --git a/sway/config.c b/sway/config.c
index ebcee95b..f520cc88 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -268,6 +268,7 @@ static char *get_config_path(void) {
268 strcat(config_home, "/.config"); 268 strcat(config_home, "/.config");
269 setenv("XDG_CONFIG_HOME", config_home, 1); 269 setenv("XDG_CONFIG_HOME", config_home, 1);
270 sway_log(L_DEBUG, "Set XDG_CONFIG_HOME to %s", config_home); 270 sway_log(L_DEBUG, "Set XDG_CONFIG_HOME to %s", config_home);
271 free(config_home);
271 } 272 }
272 273
273 wordexp_t p; 274 wordexp_t p;
@@ -276,7 +277,8 @@ static char *get_config_path(void) {
276 int i; 277 int i;
277 for (i = 0; i < (int)(sizeof(config_paths) / sizeof(char *)); ++i) { 278 for (i = 0; i < (int)(sizeof(config_paths) / sizeof(char *)); ++i) {
278 if (wordexp(config_paths[i], &p, 0) == 0) { 279 if (wordexp(config_paths[i], &p, 0) == 0) {
279 path = p.we_wordv[0]; 280 path = strdup(p.we_wordv[0]);
281 wordfree(&p);
280 if (file_exists(path)) { 282 if (file_exists(path)) {
281 return path; 283 return path;
282 } 284 }
@@ -355,6 +357,8 @@ bool load_main_config(const char *file, bool is_active) {
355 update_active_bar_modifiers(); 357 update_active_bar_modifiers();
356 } 358 }
357 359
360 free(path);
361
358 return success; 362 return success;
359} 363}
360 364
@@ -532,7 +536,7 @@ bool read_config(FILE *file, struct sway_config *config) {
532 default:; 536 default:;
533 } 537 }
534 free(line); 538 free(line);
535 free(res); 539 free_cmd_results(res);
536 } 540 }
537 541
538 return success; 542 return success;