diff --git a/common/stringop.c b/common/stringop.c index 613244585..432bee7ff 100644 --- a/common/stringop.c +++ b/common/stringop.c @@ -144,7 +144,7 @@ char **split_args(const char *start, int *argc) { } void free_argv(int argc, char **argv) { - while (--argc > 0) { + while (argc-- > 0) { free(argv[argc]); } free(argv); diff --git a/sway/config.c b/sway/config.c index ebcee95be..f520cc889 100644 --- a/sway/config.c +++ b/sway/config.c @@ -268,6 +268,7 @@ static char *get_config_path(void) { strcat(config_home, "/.config"); setenv("XDG_CONFIG_HOME", config_home, 1); sway_log(L_DEBUG, "Set XDG_CONFIG_HOME to %s", config_home); + free(config_home); } wordexp_t p; @@ -276,7 +277,8 @@ static char *get_config_path(void) { int i; for (i = 0; i < (int)(sizeof(config_paths) / sizeof(char *)); ++i) { if (wordexp(config_paths[i], &p, 0) == 0) { - path = p.we_wordv[0]; + path = strdup(p.we_wordv[0]); + wordfree(&p); if (file_exists(path)) { return path; } @@ -355,6 +357,8 @@ bool load_main_config(const char *file, bool is_active) { update_active_bar_modifiers(); } + free(path); + return success; } @@ -532,7 +536,7 @@ bool read_config(FILE *file, struct sway_config *config) { default:; } free(line); - free(res); + free_cmd_results(res); } return success;