From bf57d0c60691963e597408827b74646d368658ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 9 Jun 2020 17:32:34 +0200 Subject: [PATCH] csi: \E[3J: reset render.last_cursor.row if necessary This fixes a crash that occurred when the last rendered cursor cell had scrolled off screen, and \E[3J (clear scrollback) was executed. --- CHANGELOG.md | 2 ++ csi.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ac1f035..d11caa1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,8 @@ * Glyphs overflowing into surrounding cells (https://codeberg.org/dnkl/foot/issues/21). * Sixel images being erased when printing text next to them. +* Crash when last rendered cursor cell had scrolled off screen and + `\E[J3` was executed. ### Security diff --git a/csi.c b/csi.c index 56346e6e..37400953 100644 --- a/csi.c +++ b/csi.c @@ -506,6 +506,9 @@ csi_dispatch(struct terminal *term, uint8_t final) continue; } + if (term->render.last_cursor.row == term->grid->rows[i]) + term->render.last_cursor.row = NULL; + grid_row_free(term->grid->rows[i]); term->grid->rows[i] = NULL; }