From 8c526bbb03a5171422cf71b0217d271feeb072b6 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Sun, 1 Jul 2018 23:34:07 +0900 Subject: config include: fix leak on relative include path Found through static analysis --- sway/config.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); -- cgit v1.2.3-54-g00ecf