diff options
author | Calvin Lee <cyrus296@gmail.com> | 2017-08-16 09:23:21 +0200 |
---|---|---|
committer | Calvin Lee <cyrus296@gmail.com> | 2017-08-16 09:23:21 +0200 |
commit | 901c14c409e6e8143ade06a7478241e558cfb79c (patch) | |
tree | 8e83344aeadb70c3449baa663d02d7013c542d62 /backend/libinput | |
parent | 19d6442f52743d50d10c796d7146f58c251f67fe (diff) |
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
Diffstat (limited to 'backend/libinput')
-rw-r--r-- | backend/libinput/events.c | 5 |
1 files changed, 4 insertions, 1 deletions
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; } |