From 3cfe29b5988190d7eb32cd0b76a6cfe810be7812 Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Mon, 31 Jan 2022 20:55:52 +0300 Subject: [PATCH] cursor: ensure mapping box is always initialized Commit 498f30aad100ca616640c7bcbf11ab8ef7d48c45 changed the logic of get_mapping() in types/wlr_cursor.c to use updated version of wlr_output_layout_get_box(). However, the case where c_device isn't NULL but doesn't have output or geometry mappings wasn't handled properly, resulting in leaving the output value uninitialized. This commit fixes `c_device != NULL` branch by returning from the function only when a mapping is found. Fixes https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3369 --- types/wlr_cursor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index bab5ed10..034628cf 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -248,11 +248,12 @@ static void get_mapping(struct wlr_cursor *cur, if (c_device) { if (!wlr_box_empty(&c_device->mapped_box)) { *box = c_device->mapped_box; + return; } else if (c_device->mapped_output) { wlr_output_layout_get_box(cur->state->layout, c_device->mapped_output, box); + return; } - return; } if (!wlr_box_empty(&cur->state->mapped_box)) {