mirror of
https://github.com/swaywm/sway.git
synced 2024-12-29 16:36:26 +01:00
Shuffle variables to satisfy -Werror=restrict
This also fixes an invalid strlen invocation on uninitialized memory.
This commit is contained in:
parent
20181974c2
commit
cf413b9c0b
1 changed files with 6 additions and 6 deletions
|
@ -102,19 +102,19 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
|
|||
}
|
||||
|
||||
char *conf_path = dirname(conf);
|
||||
char *rel_path = src;
|
||||
src = malloc(strlen(conf_path) + strlen(src) + 2);
|
||||
if (!src) {
|
||||
free(rel_path);
|
||||
char *real_src = malloc(strlen(conf_path) + strlen(src) + 2);
|
||||
if (!real_src) {
|
||||
free(src);
|
||||
free(conf);
|
||||
sway_log(SWAY_ERROR, "Unable to allocate memory");
|
||||
return cmd_results_new(CMD_FAILURE,
|
||||
"Unable to allocate resources");
|
||||
}
|
||||
|
||||
snprintf(src, strlen(conf_path) + strlen(src) + 2, "%s/%s", conf_path, rel_path);
|
||||
free(rel_path);
|
||||
snprintf(real_src, strlen(conf_path) + strlen(src) + 2, "%s/%s", conf_path, src);
|
||||
free(src);
|
||||
free(conf);
|
||||
src = real_src;
|
||||
}
|
||||
|
||||
bool can_access = access(src, F_OK) != -1;
|
||||
|
|
Loading…
Reference in a new issue