diff options
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/sway/commands.c b/sway/commands.c index d87d0084..c15cb00a 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -121,6 +121,9 @@ void input_cmd_apply(struct input_config *input) { | |||
121 | for (int i = 0; i < input_devices->length; ++i) { | 121 | for (int i = 0; i < input_devices->length; ++i) { |
122 | device = input_devices->items[i]; | 122 | device = input_devices->items[i]; |
123 | char* dev_identifier = libinput_dev_unique_id(device); | 123 | char* dev_identifier = libinput_dev_unique_id(device); |
124 | if (!dev_identifier) { | ||
125 | break; | ||
126 | } | ||
124 | int match = dev_identifier && strcmp(dev_identifier, input->identifier) == 0; | 127 | int match = dev_identifier && strcmp(dev_identifier, input->identifier) == 0; |
125 | free(dev_identifier); | 128 | free(dev_identifier); |
126 | if (match) { | 129 | if (match) { |
@@ -386,7 +389,11 @@ struct cmd_results *handle_command(char *_exec, enum command_context context) { | |||
386 | if (!results) { | 389 | if (!results) { |
387 | int len = strlen(criteria) + strlen(head) + 4; | 390 | int len = strlen(criteria) + strlen(head) + 4; |
388 | char *tmp = malloc(len); | 391 | char *tmp = malloc(len); |
389 | snprintf(tmp, len, "[%s] %s", criteria, head); | 392 | if (tmp) { |
393 | snprintf(tmp, len, "[%s] %s", criteria, head); | ||
394 | } else { | ||
395 | sway_log(L_DEBUG, "Unable to allocate criteria string for cmd result"); | ||
396 | } | ||
390 | results = cmd_results_new(CMD_INVALID, tmp, | 397 | results = cmd_results_new(CMD_INVALID, tmp, |
391 | "Can't handle criteria string: Refusing to execute command"); | 398 | "Can't handle criteria string: Refusing to execute command"); |
392 | free(tmp); | 399 | free(tmp); |
@@ -568,6 +575,9 @@ struct cmd_results *config_commands_command(char *exec) { | |||
568 | } | 575 | } |
569 | if (!policy) { | 576 | if (!policy) { |
570 | policy = alloc_command_policy(cmd); | 577 | policy = alloc_command_policy(cmd); |
578 | if (!policy) { | ||
579 | sway_abort("Unable to allocate security policy"); | ||
580 | } | ||
571 | list_add(config->command_policies, policy); | 581 | list_add(config->command_policies, policy); |
572 | } | 582 | } |
573 | policy->context = context; | 583 | policy->context = context; |
@@ -584,6 +594,10 @@ cleanup: | |||
584 | 594 | ||
585 | struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, const char *format, ...) { | 595 | struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, const char *format, ...) { |
586 | struct cmd_results *results = malloc(sizeof(struct cmd_results)); | 596 | struct cmd_results *results = malloc(sizeof(struct cmd_results)); |
597 | if (!results) { | ||
598 | sway_log(L_ERROR, "Unable to allocate command results"); | ||
599 | return NULL; | ||
600 | } | ||
587 | results->status = status; | 601 | results->status = status; |
588 | if (input) { | 602 | if (input) { |
589 | results->input = strdup(input); // input is the command name | 603 | results->input = strdup(input); // input is the command name |
@@ -594,7 +608,9 @@ struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, c | |||
594 | char *error = malloc(256); | 608 | char *error = malloc(256); |
595 | va_list args; | 609 | va_list args; |
596 | va_start(args, format); | 610 | va_start(args, format); |
597 | vsnprintf(error, 256, format, args); | 611 | if (error) { |
612 | vsnprintf(error, 256, format, args); | ||
613 | } | ||
598 | va_end(args); | 614 | va_end(args); |
599 | results->error = error; | 615 | results->error = error; |
600 | } else { | 616 | } else { |