aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/assign.c5
-rw-r--r--sway/commands/output.c3
-rw-r--r--sway/commands/workspace.c4
-rw-r--r--sway/config.c3
-rw-r--r--sway/container.c3
-rw-r--r--sway/extensions.c4
-rw-r--r--sway/input.c10
-rw-r--r--sway/ipc-json.c9
8 files changed, 39 insertions, 2 deletions
diff --git a/sway/commands/assign.c b/sway/commands/assign.c
index 1824692b..992b4692 100644
--- a/sway/commands/assign.c
+++ b/sway/commands/assign.c
@@ -23,11 +23,14 @@ struct cmd_results *cmd_assign(int argc, char **argv) {
char *movecmd = "move container to workspace ";
int arglen = strlen(movecmd) + strlen(*argv) + 1;
char *cmdlist = calloc(1, arglen);
-
+ if (!cmdlist) {
+ return cmd_results_new(CMD_FAILURE, "assign", "Unable to allocate command list");
+ }
snprintf(cmdlist, arglen, "%s%s", movecmd, *argv);
struct criteria *crit = malloc(sizeof(struct criteria));
if (!crit) {
+ free(cmdlist);
return cmd_results_new(CMD_FAILURE, "assign", "Unable to allocate criteria");
}
crit->crit_raw = strdup(criteria);
diff --git a/sway/commands/output.c b/sway/commands/output.c
index e150aed2..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) {
const char *name = argv[0];
struct output_config *output = calloc(1, sizeof(struct output_config));
+ if (!output) {
+ return cmd_results_new(CMD_FAILURE, "output", "Unable to allocate output config");
+ }
output->x = output->y = output->width = output->height = -1;
output->name = strdup(name);
output->enabled = -1;
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c
index 35224f8a..14fe242f 100644
--- a/sway/commands/workspace.c
+++ b/sway/commands/workspace.c
@@ -61,6 +61,10 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
return error;
}
struct workspace_output *wso = calloc(1, sizeof(struct workspace_output));
+ if (!wso) {
+ return cmd_results_new(CMD_FAILURE, "workspace output",
+ "Unable to allocate workspace output");
+ }
wso->workspace = strdup(argv[0]);
wso->output = strdup(argv[2]);
int i = -1;
diff --git a/sway/config.c b/sway/config.c
index b86bacdb..4164cefa 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -494,6 +494,9 @@ bool load_main_config(const char *file, bool is_active) {
struct sway_config *old_config = config;
config = calloc(1, sizeof(struct sway_config));
+ if (!config) {
+ sway_abort("Unable to allocate config");
+ }
config_defaults(config);
if (is_active) {
diff --git a/sway/container.c b/sway/container.c
index 8a584efa..d9677cdb 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -23,6 +23,9 @@ static swayc_t *new_swayc(enum swayc_types type) {
// next id starts at 1 because 0 is assigned to root_container in layout.c
static size_t next_id = 1;
swayc_t *c = calloc(1, sizeof(swayc_t));
+ if (!c) {
+ return NULL;
+ }
c->id = next_id++;
c->handle = -1;
c->gaps = -1;
diff --git a/sway/extensions.c b/sway/extensions.c
index 759cbb84..40702e28 100644
--- a/sway/extensions.c
+++ b/sway/extensions.c
@@ -23,6 +23,10 @@ static struct panel_config *find_or_create_panel_config(struct wl_resource *reso
}
sway_log(L_DEBUG, "Creating panel config for resource %p", resource);
struct panel_config *config = calloc(1, sizeof(struct panel_config));
+ if (!config) {
+ sway_log(L_ERROR, "Unable to create panel config");
+ return NULL;
+ }
list_add(desktop_shell.panels, config);
config->wl_resource = resource;
return config;
diff --git a/sway/input.c b/sway/input.c
index 61757ab8..249d95c6 100644
--- a/sway/input.c
+++ b/sway/input.c
@@ -11,8 +11,16 @@
struct input_config *new_input_config(const char* identifier) {
struct input_config *input = calloc(1, sizeof(struct input_config));
+ if (!input) {
+ sway_log(L_DEBUG, "Unable to allocate input config");
+ return NULL;
+ }
sway_log(L_DEBUG, "new_input_config(%s)", identifier);
- input->identifier = strdup(identifier);
+ if (!(input->identifier = strdup(identifier))) {
+ free(input);
+ sway_log(L_DEBUG, "Unable to allocate input config");
+ return NULL;
+ }
input->tap = INT_MIN;
input->drag_lock = INT_MIN;
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index e65e9de3..fd17216e 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -245,6 +245,15 @@ json_object *ipc_json_get_version() {
#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE
char *full_version = calloc(strlen(SWAY_GIT_VERSION) + strlen(SWAY_GIT_BRANCH) + strlen(SWAY_VERSION_DATE) + 20, 1);
+ if (!full_version) {
+ json_object_object_add(version, "human_readable",
+ json_object_new_string("Allocating version string failed"));
+ // TODO: it's stupid that we allocate this in the first place
+ json_object_object_add(version, "major", json_object_new_int(0));
+ json_object_object_add(version, "minor", json_object_new_int(0));
+ json_object_object_add(version, "patch", json_object_new_int(0));
+ return version;
+ }
strcat(full_version, SWAY_GIT_VERSION);
strcat(full_version, " (");
strcat(full_version, SWAY_VERSION_DATE);