mirror of
https://github.com/swaywm/sway.git
synced 2025-11-17 06:59:48 -05:00
Handle allocation failure in commands
This commit is contained in:
parent
8691ff1b63
commit
248df18c24
11 changed files with 78 additions and 16 deletions
|
|
@ -113,12 +113,20 @@ struct cmd_results *cmd_output(int argc, char **argv) {
|
|||
src = p.we_wordv[0];
|
||||
if (config->reading && *src != '/') {
|
||||
char *conf = strdup(config->current_config);
|
||||
char *conf_path = dirname(conf);
|
||||
src = malloc(strlen(conf_path) + strlen(src) + 2);
|
||||
sprintf(src, "%s/%s", conf_path, p.we_wordv[0]);
|
||||
free(conf);
|
||||
if (conf) {
|
||||
char *conf_path = dirname(conf);
|
||||
src = malloc(strlen(conf_path) + strlen(src) + 2);
|
||||
if (src) {
|
||||
sprintf(src, "%s/%s", conf_path, p.we_wordv[0]);
|
||||
} else {
|
||||
sway_log(L_ERROR, "Unable to allocate background source");
|
||||
}
|
||||
free(conf);
|
||||
} else {
|
||||
sway_log(L_ERROR, "Unable to allocate background source");
|
||||
}
|
||||
}
|
||||
if (access(src, F_OK) == -1) {
|
||||
if (!src || access(src, F_OK) == -1) {
|
||||
return cmd_results_new(CMD_INVALID, "output", "Background file unreadable (%s)", src);
|
||||
}
|
||||
for (char *m = mode; *m; ++m) *m = tolower(*m);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue