From 01b3e7ed9271e49ae571918a912e0783d272abac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 24 Jun 2026 13:03:14 +0200 Subject: [PATCH] csi: kitty: limit pop count to the size of the flag stack It's circular, but there's no need to walk through it more than once... csi: kitty: limit pop count to the size of the flag stack It's circular, but there's no need to walk through it more than once... --- csi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/csi.c b/csi.c index a82c0e2c..ed643090 100644 --- a/csi.c +++ b/csi.c @@ -1769,10 +1769,10 @@ csi_dispatch(struct terminal *term, uint8_t final) case '<': { switch (final) { case 'u': { - int count = vt_param_get(term, 0, 1); + struct grid *grid = term->grid; + int count = min(vt_param_get(term, 0, 1), ALEN(grid->kitty_kbd.flags)); LOG_DBG("kitty kbd: popping %d levels of flags", count); - struct grid *grid = term->grid; uint8_t idx = grid->kitty_kbd.idx; for (int i = 0; i < count; i++) {