diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2018-07-01 23:34:07 +0900 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2018-07-02 08:03:41 +0900 |
commit | 8c526bbb03a5171422cf71b0217d271feeb072b6 (patch) | |
tree | 14cb669926f9b5a13521e944e2f19997053b902a | |
parent | 248ea93c1af7eae5a57c354b0e2e50898f57b17d (diff) |
config include: fix leak on relative include path
Found through static analysis
-rw-r--r-- | sway/config.c | 4 |
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, // save parent config const char *parent_config = config->current_config; - char *full_path = strdup(path); + char *full_path; int len = strlen(path); if (len >= 1 && path[0] != '/') { len = len + strlen(parent_dir) + 2; @@ -436,6 +436,8 @@ static bool load_include_config(const char *path, const char *parent_dir, return false; } snprintf(full_path, len, "%s/%s", parent_dir, path); + } else { + full_path = strdup(path); } char *real_path = realpath(full_path, NULL); |