From 1472dbda74dea5387a4d0e531b641734131dc705 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Thu, 9 Nov 2017 18:32:54 -0500 Subject: rootston: roots_keyboard null check --- rootston/keyboard.c | 4 ++++ rootston/seat.c | 5 +++++ 2 files changed, 9 insertions(+) (limited to 'rootston') diff --git a/rootston/keyboard.c b/rootston/keyboard.c index 72567eef..bb748550 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -249,6 +249,10 @@ struct roots_keyboard *roots_keyboard_create(struct wlr_input_device *device, keyboard->input = input; struct keyboard_config *config = calloc(1, sizeof(struct keyboard_config)); + if (config == NULL) { + free(keyboard); + return NULL; + } keyboard_config_merge(config, config_get_keyboard(input->config, device)); keyboard_config_merge(config, config_get_keyboard(input->config, NULL)); diff --git a/rootston/seat.c b/rootston/seat.c index 97d5c7e4..72e94aec 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -306,6 +306,11 @@ void roots_seat_destroy(struct roots_seat *seat) { static void seat_add_keyboard(struct roots_seat *seat, struct wlr_input_device *device) { assert(device->type == WLR_INPUT_DEVICE_KEYBOARD); struct roots_keyboard *keyboard = roots_keyboard_create(device, seat->input); + if (keyboard == NULL) { + wlr_log(L_ERROR, "could not allocate keyboard for seat"); + return; + } + keyboard->seat = seat; wl_list_insert(&seat->keyboards, &keyboard->link); -- cgit v1.2.3