diff options
Diffstat (limited to 'sway/commands/output/background.c')
-rw-r--r-- | sway/commands/output/background.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sway/commands/output/background.c b/sway/commands/output/background.c index 67f212ff..68ee9fe1 100644 --- a/sway/commands/output/background.c +++ b/sway/commands/output/background.c @@ -102,19 +102,19 @@ struct cmd_results *output_cmd_background(int argc, char **argv) { } char *conf_path = dirname(conf); - char *real_src = malloc(strlen(conf_path) + strlen(src) + 2); - if (!real_src) { - free(src); + char *rel_path = src; + src = malloc(strlen(conf_path) + strlen(src) + 2); + if (!src) { + free(rel_path); free(conf); sway_log(SWAY_ERROR, "Unable to allocate memory"); return cmd_results_new(CMD_FAILURE, "Unable to allocate resources"); } - snprintf(real_src, strlen(conf_path) + strlen(src) + 2, "%s/%s", conf_path, src); - free(src); + sprintf(src, "%s/%s", conf_path, rel_path); + free(rel_path); free(conf); - src = real_src; } bool can_access = access(src, F_OK) != -1; |