mirror of
https://github.com/swaywm/sway.git
synced 2025-01-08 09:01:13 +00:00
Restore CWD if returning early.
This commit is contained in:
parent
855368b67e
commit
921e42c6c0
|
@ -558,17 +558,13 @@ bool load_include_configs(const char *path, struct sway_config *config,
|
||||||
const char *parent_dir = dirname(parent_path);
|
const char *parent_dir = dirname(parent_path);
|
||||||
|
|
||||||
if (chdir(parent_dir) < 0) {
|
if (chdir(parent_dir) < 0) {
|
||||||
free(parent_path);
|
goto error_chdir;
|
||||||
free(wd);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wordexp_t p;
|
wordexp_t p;
|
||||||
|
|
||||||
if (wordexp(path, &p, 0) != 0) {
|
if (wordexp(path, &p, 0) != 0) {
|
||||||
free(parent_path);
|
goto error_wordexp;
|
||||||
free(wd);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char **w = p.we_wordv;
|
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) {
|
for (i = 0; i < p.we_wordc; ++i) {
|
||||||
bool found = load_include_config(w[i], parent_dir, config, swaynag);
|
bool found = load_include_config(w[i], parent_dir, config, swaynag);
|
||||||
if (!found) {
|
if (!found) {
|
||||||
wordfree(&p);
|
goto error_not_found;
|
||||||
free(parent_path);
|
|
||||||
free(wd);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(parent_path);
|
free(parent_path);
|
||||||
|
@ -594,6 +587,16 @@ bool load_include_configs(const char *path, struct sway_config *config,
|
||||||
|
|
||||||
free(wd);
|
free(wd);
|
||||||
return true;
|
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) {
|
void run_deferred_commands(void) {
|
||||||
|
|
Loading…
Reference in a new issue