From 85d72b9952ba49cf796d2e464c9adef0540b00b5 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 8 Jun 2026 15:16:21 +0000 Subject: [PATCH] Return immediately if the list is empty in mode_tree_key instead of crashing, from Bryce Miller in GitHub issue 5170. --- mode-tree.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mode-tree.c b/mode-tree.c index 6479d78d..82535497 100644 --- a/mode-tree.c +++ b/mode-tree.c @@ -1224,6 +1224,11 @@ mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key, u_int i, x, y; int choice, preview; + if (mtd->line_size == 0) { + *key = KEYC_NONE; + return (1); + } + if (KEYC_IS_MOUSE(*key) && m != NULL) { if (cmd_mouse_at(mtd->wp, m, &x, &y, 0) != 0) { *key = KEYC_NONE;