aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config.c
diff options
context:
space:
mode:
authorLibravatar Dominique Martinet <asmadeus@codewreck.org>2018-07-01 23:34:07 +0900
committerLibravatar Dominique Martinet <asmadeus@codewreck.org>2018-07-02 08:03:41 +0900
commit8c526bbb03a5171422cf71b0217d271feeb072b6 (patch)
tree14cb669926f9b5a13521e944e2f19997053b902a /sway/config.c
parentbar config: fix uninitialized accesses on init error (diff)
downloadsway-8c526bbb03a5171422cf71b0217d271feeb072b6.tar.gz
sway-8c526bbb03a5171422cf71b0217d271feeb072b6.tar.zst
sway-8c526bbb03a5171422cf71b0217d271feeb072b6.zip
config include: fix leak on relative include path
Found through static analysis
Diffstat (limited to 'sway/config.c')
-rw-r--r--sway/config.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sway/config.c b/sway/config.c
index d3040a67..8b6f7b6f 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -425,7 +425,7 @@ static bool load_include_config(const char *path, const char *parent_dir,
425 // save parent config 425 // save parent config
426 const char *parent_config = config->current_config; 426 const char *parent_config = config->current_config;
427 427
428 char *full_path = strdup(path); 428 char *full_path;
429 int len = strlen(path); 429 int len = strlen(path);
430 if (len >= 1 && path[0] != '/') { 430 if (len >= 1 && path[0] != '/') {
431 len = len + strlen(parent_dir) + 2; 431 len = len + strlen(parent_dir) + 2;
@@ -436,6 +436,8 @@ static bool load_include_config(const char *path, const char *parent_dir,
436 return false; 436 return false;
437 } 437 }
438 snprintf(full_path, len, "%s/%s", parent_dir, path); 438 snprintf(full_path, len, "%s/%s", parent_dir, path);
439 } else {
440 full_path = strdup(path);
439 } 441 }
440 442
441 char *real_path = realpath(full_path, NULL); 443 char *real_path = realpath(full_path, NULL);