From 901c14c409e6e8143ade06a7478241e558cfb79c Mon Sep 17 00:00:00 2001 From: Calvin Lee Date: Wed, 16 Aug 2017 09:23:21 +0200 Subject: Prevent alloc errors from crashing in `list_t` This commit changes the `list_t` api so that alloc errors can be detected and worked around. Also fixes errors not found in 5cc7342 --- backend/libinput/events.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'backend/libinput/events.c') diff --git a/backend/libinput/events.c b/backend/libinput/events.c index dc5e4cb1..2a396536 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -44,11 +44,14 @@ static struct wlr_input_device *allocate_device( return NULL; } struct wlr_input_device *wlr_dev = &wlr_libinput_dev->wlr_input_device; + if (list_add(wlr_devices, wlr_dev) == -1) { + free(wlr_libinput_dev); + return NULL; + } wlr_libinput_dev->handle = libinput_dev; libinput_device_ref(libinput_dev); wlr_input_device_init(wlr_dev, type, &input_device_impl, name, vendor, product); - list_add(wlr_devices, wlr_dev); return wlr_dev; } -- cgit v1.2.3