aboutsummaryrefslogtreecommitdiff
path: root/sway/handlers.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2016-12-17 13:23:44 -0500
committerGitHub <noreply@github.com>2016-12-17 13:23:44 -0500
commitf04ee0e68d885d7e1101cc88f9a9337202041f1f (patch)
treefa4dc296a5f1377867752d320ceef4e4b0178bbf /sway/handlers.c
parent6c0fc2093641868df28c4087902a040f7fae05d4 (diff)
parentd859f825d3612492678f5cd6cc6dc1f2647929e1 (diff)
Merge pull request #995 from SirCmpwn/memory-use
Handle allocation failures
Diffstat (limited to 'sway/handlers.c')
-rw-r--r--sway/handlers.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index 86a976d8..3abe2fca 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -123,6 +123,11 @@ static void update_background_geometries(wlc_handle output) {
static bool handle_input_created(struct libinput_device *device) {
const char *identifier = libinput_dev_unique_id(device);
+ if (!identifier) {
+ sway_log(L_ERROR, "Unable to allocate unique name for input device %p",
+ device);
+ return true;
+ }
sway_log(L_INFO, "Found input device (%s)", identifier);
list_add(input_devices, device);
@@ -402,6 +407,10 @@ static bool handle_view_created(wlc_handle handle) {
} else {
swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT);
wlc_handle *h = malloc(sizeof(wlc_handle));
+ if (!h) {
+ sway_log(L_ERROR, "Unable to allocate window handle, view handler bailing out");
+ return true;
+ }
*h = handle;
sway_log(L_DEBUG, "Adding unmanaged window %p to %p", h, output->unmanaged);
list_add(output->unmanaged, h);
@@ -571,6 +580,10 @@ static void handle_binding_command(struct sway_binding *binding) {
// binding since it will be gone after the reload has completed.
if (strcasecmp(binding->command, "reload") == 0) {
binding_copy = sway_binding_dup(binding);
+ if (!binding_copy) {
+ sway_log(L_ERROR, "Unable to duplicate binding during reload");
+ return;
+ }
reload = true;
}