From 5cc7342606dbbd5e6932b39e6b1b5645164669bf Mon Sep 17 00:00:00 2001 From: Calvin Lee Date: Tue, 15 Aug 2017 07:56:47 +0200 Subject: Prevent alloc errors from crashing Resolves #76 --- backend/multi/backend.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'backend/multi') diff --git a/backend/multi/backend.c b/backend/multi/backend.c index 9afca47d..290b9678 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -115,7 +115,11 @@ void wlr_multi_backend_add(struct wlr_backend *_multi, assert(wlr_backend_is_multi(_multi)); struct wlr_multi_backend *multi = (struct wlr_multi_backend *)_multi; - struct subbackend_state *sub = calloc(1, sizeof(struct subbackend_state)); + struct subbackend_state *sub; + if (!(sub = calloc(1, sizeof(struct subbackend_state)))) { + wlr_log(L_ERROR, "Could not add backend: allocation failed"); + return; + } sub->backend = backend; sub->container = &multi->backend; -- cgit v1.2.3