mirror of
https://github.com/swaywm/sway.git
synced 2024-12-30 17:06:40 +01:00
config include: fix leak on relative include path
Found through static analysis
This commit is contained in:
parent
248ea93c1a
commit
8c526bbb03
1 changed files with 3 additions and 1 deletions
|
@ -425,7 +425,7 @@ static bool load_include_config(const char *path, const char *parent_dir,
|
||||||
// save parent config
|
// save parent config
|
||||||
const char *parent_config = config->current_config;
|
const char *parent_config = config->current_config;
|
||||||
|
|
||||||
char *full_path = strdup(path);
|
char *full_path;
|
||||||
int len = strlen(path);
|
int len = strlen(path);
|
||||||
if (len >= 1 && path[0] != '/') {
|
if (len >= 1 && path[0] != '/') {
|
||||||
len = len + strlen(parent_dir) + 2;
|
len = len + strlen(parent_dir) + 2;
|
||||||
|
@ -436,6 +436,8 @@ static bool load_include_config(const char *path, const char *parent_dir,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
snprintf(full_path, len, "%s/%s", parent_dir, path);
|
snprintf(full_path, len, "%s/%s", parent_dir, path);
|
||||||
|
} else {
|
||||||
|
full_path = strdup(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *real_path = realpath(full_path, NULL);
|
char *real_path = realpath(full_path, NULL);
|
||||||
|
|
Loading…
Reference in a new issue