]> git.mdlowis.com Git - proto/labwc.git/commitdiff
fix crash when changing TTY
authorbi4k8 <bi4k8@github>
Sun, 20 Mar 2022 22:07:14 +0000 (22:07 +0000)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 21 Mar 2022 21:08:48 +0000 (21:08 +0000)
also add an assertion to clarify the contract of `output_by_name`

src/seat.c

index 9a3b966a2d232861c143730cc923209ec8320ede..ead27b10e91d76d1884f0129724a10e4a89eea78 100644 (file)
@@ -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);
        }