aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/bar.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/bar.c')
-rw-r--r--sway/commands/bar.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sway/commands/bar.c b/sway/commands/bar.c
index 55cb0d9d..e8d24084 100644
--- a/sway/commands/bar.c
+++ b/sway/commands/bar.c
@@ -32,6 +32,9 @@ struct cmd_results *cmd_bar(int argc, char **argv) {
32 32
33 // Create new bar with default values 33 // Create new bar with default values
34 struct bar_config *bar = default_bar_config(); 34 struct bar_config *bar = default_bar_config();
35 if (!bar) {
36 return cmd_results_new(CMD_FAILURE, "bar", "Unable to allocate bar state");
37 }
35 38
36 // set bar id 39 // set bar id
37 int i; 40 int i;
@@ -39,7 +42,11 @@ struct cmd_results *cmd_bar(int argc, char **argv) {
39 if (bar == config->bars->items[i]) { 42 if (bar == config->bars->items[i]) {
40 const int len = 5 + numlen(i); // "bar-" + i + \0 43 const int len = 5 + numlen(i); // "bar-" + i + \0
41 bar->id = malloc(len * sizeof(char)); 44 bar->id = malloc(len * sizeof(char));
42 snprintf(bar->id, len, "bar-%d", i); 45 if (bar->id) {
46 snprintf(bar->id, len, "bar-%d", i);
47 } else {
48 return cmd_results_new(CMD_FAILURE, "bar", "Unable to allocate bar ID");
49 }
43 break; 50 break;
44 } 51 }
45 } 52 }