summaryrefslogtreecommitdiffstats
path: root/sway/commands/output.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/output.c')
-rw-r--r--sway/commands/output.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/sway/commands/output.c b/sway/commands/output.c
index 6c1c55b5..01ac9f4e 100644
--- a/sway/commands/output.c
+++ b/sway/commands/output.c
@@ -26,6 +26,9 @@ struct cmd_results *cmd_output(int argc, char **argv) {
26 const char *name = argv[0]; 26 const char *name = argv[0];
27 27
28 struct output_config *output = calloc(1, sizeof(struct output_config)); 28 struct output_config *output = calloc(1, sizeof(struct output_config));
29 if (!output) {
30 return cmd_results_new(CMD_FAILURE, "output", "Unable to allocate output config");
31 }
29 output->x = output->y = output->width = output->height = -1; 32 output->x = output->y = output->width = output->height = -1;
30 output->name = strdup(name); 33 output->name = strdup(name);
31 output->enabled = -1; 34 output->enabled = -1;
@@ -113,12 +116,20 @@ struct cmd_results *cmd_output(int argc, char **argv) {
113 src = p.we_wordv[0]; 116 src = p.we_wordv[0];
114 if (config->reading && *src != '/') { 117 if (config->reading && *src != '/') {
115 char *conf = strdup(config->current_config); 118 char *conf = strdup(config->current_config);
116 char *conf_path = dirname(conf); 119 if (conf) {
117 src = malloc(strlen(conf_path) + strlen(src) + 2); 120 char *conf_path = dirname(conf);
118 sprintf(src, "%s/%s", conf_path, p.we_wordv[0]); 121 src = malloc(strlen(conf_path) + strlen(src) + 2);
119 free(conf); 122 if (src) {
123 sprintf(src, "%s/%s", conf_path, p.we_wordv[0]);
124 } else {
125 sway_log(L_ERROR, "Unable to allocate background source");
126 }
127 free(conf);
128 } else {
129 sway_log(L_ERROR, "Unable to allocate background source");
130 }
120 } 131 }
121 if (access(src, F_OK) == -1) { 132 if (!src || access(src, F_OK) == -1) {
122 return cmd_results_new(CMD_INVALID, "output", "Background file unreadable (%s)", src); 133 return cmd_results_new(CMD_INVALID, "output", "Background file unreadable (%s)", src);
123 } 134 }
124 for (char *m = mode; *m; ++m) *m = tolower(*m); 135 for (char *m = mode; *m; ++m) *m = tolower(*m);