aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorConnor E <38229097+c-edw@users.noreply.github.com>2019-02-06 15:42:32 +0000
committeremersion <contact@emersion.fr>2019-02-06 18:23:20 +0100
commit921e42c6c06212a61d899d6335d95eb4c781e2e8 (patch)
tree1799560336318601661978f99340f2c17ec03447 /sway
parent855368b67e8b7d0b1dd035bde7f9119d37b35e5d (diff)
Restore CWD if returning early.
Diffstat (limited to 'sway')
-rw-r--r--sway/config.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/sway/config.c b/sway/config.c
index 455d20cd..9072f7d7 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -558,17 +558,13 @@ bool load_include_configs(const char *path, struct sway_config *config,
const char *parent_dir = dirname(parent_path);
if (chdir(parent_dir) < 0) {
- free(parent_path);
- free(wd);
- return false;
+ goto error_chdir;
}
wordexp_t p;
if (wordexp(path, &p, 0) != 0) {
- free(parent_path);
- free(wd);
- return false;
+ goto error_wordexp;
}
char **w = p.we_wordv;
@@ -576,10 +572,7 @@ bool load_include_configs(const char *path, struct sway_config *config,
for (i = 0; i < p.we_wordc; ++i) {
bool found = load_include_config(w[i], parent_dir, config, swaynag);
if (!found) {
- wordfree(&p);
- free(parent_path);
- free(wd);
- return false;
+ goto error_not_found;
}
}
free(parent_path);
@@ -594,6 +587,16 @@ bool load_include_configs(const char *path, struct sway_config *config,
free(wd);
return true;
+error_not_found:
+ wordfree(&p);
+error_wordexp:
+ if (chdir(wd) < 0) {
+ sway_log(SWAY_ERROR, "failed to restore working directory");
+ }
+error_chdir:
+ free(parent_path);
+ free(wd);
+ return false;
}
void run_deferred_commands(void) {