From 401b282772094bf7423df9865949a18f8a9c4a92 Mon Sep 17 00:00:00 2001 From: bi4k8 Date: Sun, 20 Mar 2022 22:07:14 +0000 Subject: [PATCH] fix crash when changing TTY also add an assertion to clarify the contract of `output_by_name` --- src/seat.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/seat.c b/src/seat.c index 9a3b966a..ead27b10 100644 --- a/src/seat.c +++ b/src/seat.c @@ -128,6 +128,7 @@ configure_libinput(struct wlr_input_device *wlr_input_device) static struct wlr_output * output_by_name(struct server *server, const char *name) { + assert(name != NULL); struct output *output; wl_list_for_each(output, &server->outputs, link) { if (!strcasecmp(output->wlr_output->name, name)) { @@ -150,8 +151,10 @@ new_pointer(struct seat *seat, struct input *input) if (dev->type == WLR_INPUT_DEVICE_POINTER) { wlr_log(WLR_INFO, "map pointer to output %s\n", dev->pointer->output_name); - struct wlr_output *output = - output_by_name(seat->server, dev->pointer->output_name); + struct wlr_output *output = NULL; + if (dev->pointer->output_name != NULL) { + output = output_by_name(seat->server, dev->pointer->output_name); + } wlr_cursor_map_input_to_output(seat->cursor, dev, output); wlr_cursor_map_input_to_region(seat->cursor, dev, NULL); }