aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/output/background.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/output/background.c')
-rw-r--r--sway/commands/output/background.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sway/commands/output/background.c b/sway/commands/output/background.c
index 1a3939d4..67f212ff 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) {
102 } 102 }
103 103
104 char *conf_path = dirname(conf); 104 char *conf_path = dirname(conf);
105 char *rel_path = src; 105 char *real_src = malloc(strlen(conf_path) + strlen(src) + 2);
106 src = malloc(strlen(conf_path) + strlen(src) + 2); 106 if (!real_src) {
107 if (!src) { 107 free(src);
108 free(rel_path);
109 free(conf); 108 free(conf);
110 sway_log(SWAY_ERROR, "Unable to allocate memory"); 109 sway_log(SWAY_ERROR, "Unable to allocate memory");
111 return cmd_results_new(CMD_FAILURE, 110 return cmd_results_new(CMD_FAILURE,
112 "Unable to allocate resources"); 111 "Unable to allocate resources");
113 } 112 }
114 113
115 snprintf(src, strlen(conf_path) + strlen(src) + 2, "%s/%s", conf_path, rel_path); 114 snprintf(real_src, strlen(conf_path) + strlen(src) + 2, "%s/%s", conf_path, src);
116 free(rel_path); 115 free(src);
117 free(conf); 116 free(conf);
117 src = real_src;
118 } 118 }
119 119
120 bool can_access = access(src, F_OK) != -1; 120 bool can_access = access(src, F_OK) != -1;