1
1
Fork 0
mirror of https://github.com/swaywm/sway synced 2024-05-24 22:36:19 +02:00

config include: fix leak on relative include path

Found through static analysis
This commit is contained in:
Dominique Martinet 2018-07-01 23:34:07 +09:00
parent 248ea93c1a
commit 8c526bbb03

View File

@ -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);