From b4a74bcebc8f1d37b2ed78db3440435ead03299a Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 4 Mar 2016 07:50:49 +1000 Subject: [PATCH] Assert that the interface is actually filled in. Had this in a private bug report recently. Missing hooks for open/close just segfault with little information to debug. Add an assert, this is definitely a bug in the caller and we don't need to recover from that. Signed-off-by: Peter Hutterer --- src/libinput.c | 3 +++ test/udev.c | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libinput.c b/src/libinput.c index 3c78905f..14808780 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -1517,6 +1517,9 @@ libinput_init(struct libinput *libinput, const struct libinput_interface_backend *interface_backend, void *user_data) { + assert(interface->open_restricted != NULL); + assert(interface->close_restricted != NULL); + libinput->epoll_fd = epoll_create1(EPOLL_CLOEXEC);; if (libinput->epoll_fd < 0) return -1; diff --git a/test/udev.c b/test/udev.c index 30ae1180..9296e94c 100644 --- a/test/udev.c +++ b/test/udev.c @@ -52,7 +52,6 @@ const struct libinput_interface simple_interface = { START_TEST(udev_create_NULL) { struct libinput *li; - const struct libinput_interface interface; struct udev *udev; udev = udev_new(); @@ -60,13 +59,13 @@ START_TEST(udev_create_NULL) li = libinput_udev_create_context(NULL, NULL, NULL); ck_assert(li == NULL); - li = libinput_udev_create_context(&interface, NULL, NULL); + li = libinput_udev_create_context(&simple_interface, NULL, NULL); ck_assert(li == NULL); li = libinput_udev_create_context(NULL, NULL, udev); ck_assert(li == NULL); - li = libinput_udev_create_context(&interface, NULL, udev); + li = libinput_udev_create_context(&simple_interface, NULL, udev); ck_assert(li != NULL); ck_assert_int_eq(libinput_udev_assign_seat(li, NULL), -1);