aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/output.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/output.c')
-rw-r--r--sway/commands/output.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/sway/commands/output.c b/sway/commands/output.c
index 6c1c55b5..e150aed2 100644
--- a/sway/commands/output.c
+++ b/sway/commands/output.c
@@ -113,12 +113,20 @@ struct cmd_results *cmd_output(int argc, char **argv) {
113 src = p.we_wordv[0]; 113 src = p.we_wordv[0];
114 if (config->reading && *src != '/') { 114 if (config->reading && *src != '/') {
115 char *conf = strdup(config->current_config); 115 char *conf = strdup(config->current_config);
116 char *conf_path = dirname(conf); 116 if (conf) {
117 src = malloc(strlen(conf_path) + strlen(src) + 2); 117 char *conf_path = dirname(conf);
118 sprintf(src, "%s/%s", conf_path, p.we_wordv[0]); 118 src = malloc(strlen(conf_path) + strlen(src) + 2);
119 free(conf); 119 if (src) {
120 sprintf(src, "%s/%s", conf_path, p.we_wordv[0]);
121 } else {
122 sway_log(L_ERROR, "Unable to allocate background source");
123 }
124 free(conf);
125 } else {
126 sway_log(L_ERROR, "Unable to allocate background source");
127 }
120 } 128 }
121 if (access(src, F_OK) == -1) { 129 if (!src || access(src, F_OK) == -1) {
122 return cmd_results_new(CMD_INVALID, "output", "Background file unreadable (%s)", src); 130 return cmd_results_new(CMD_INVALID, "output", "Background file unreadable (%s)", src);
123 } 131 }
124 for (char *m = mode; *m; ++m) *m = tolower(*m); 132 for (char *m = mode; *m; ++m) *m = tolower(*m);