diff options
author | Calvin Lee <cyrus296@gmail.com> | 2017-08-15 07:56:47 +0200 |
---|---|---|
committer | Calvin Lee <cyrus296@gmail.com> | 2017-08-15 08:04:57 +0200 |
commit | 5cc7342606dbbd5e6932b39e6b1b5645164669bf (patch) | |
tree | f4cdef098650e5d0ac2f9ca3237f2f789db1d3fe /backend/libinput/keyboard.c | |
parent | 5ca88af557178c0081fd408ae008686b79d6dd9c (diff) |
Prevent alloc errors from crashing
Resolves #76
Diffstat (limited to 'backend/libinput/keyboard.c')
-rw-r--r-- | backend/libinput/keyboard.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/backend/libinput/keyboard.c b/backend/libinput/keyboard.c index db4ac0ed..1c52a6b8 100644 --- a/backend/libinput/keyboard.c +++ b/backend/libinput/keyboard.c @@ -32,8 +32,10 @@ struct wlr_keyboard_impl impl = { struct wlr_keyboard *wlr_libinput_keyboard_create( struct libinput_device *libinput_dev) { assert(libinput_dev); - struct wlr_libinput_keyboard *wlr_libinput_kb = - calloc(1, sizeof(struct wlr_libinput_keyboard)); + struct wlr_libinput_keyboard *wlr_libinput_kb; + if (!(wlr_libinput_kb= calloc(1, sizeof(struct wlr_libinput_keyboard)))) { + return NULL; + } wlr_libinput_kb->libinput_dev = libinput_dev; libinput_device_ref(libinput_dev); libinput_device_led_update(libinput_dev, 0); |