From d0c5cf6e9fa3c7f85531cfc3d3166c2cf7b6707e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 5 Oct 2020 18:33:50 +0200 Subject: [PATCH] =?UTF-8?q?sixel:=20reflow:=20drop=20sixels=20that=20cross?= =?UTF-8?q?es=20the=20scrollback=20history=E2=80=99s=20end?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes various crashes that occurred after a reflow due to the sixel image list invariants no longer being true. --- sixel.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sixel.c b/sixel.c index 0b971a90..898b8713 100644 --- a/sixel.c +++ b/sixel.c @@ -643,6 +643,29 @@ sixel_reflow(struct terminal *term) continue; } + /* Drop sixels that now cross the current scrollback end + * border. This is similar to a sixel that have been + * scrolled out */ + /* TODO: should be possible to optimize this */ + bool sixel_destroyed = false; + int last_row = -1; + + for (int j = 0; j < six->rows; j++) { + int row_no = rebase_row(term, six->pos.row + j); + if (last_row != -1 && last_row >= row_no) { + sixel_destroy(six); + sixel_destroyed = true; + break; + } + + last_row = row_no; + } + + if (sixel_destroyed) { + LOG_WARN("destroyed sixel that now crossed history"); + continue; + } + /* Sixels that didn’t overlap may now do so, which isn’t * allowed of course */ _sixel_overwrite_by_rectangle(