aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-10-05 16:33:50 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-10-11 17:26:09 +0000
commitd0c5cf6e9fa3c7f85531cfc3d3166c2cf7b6707e (patch)
tree06cb4321c7af76017e95347f4b3df6c07f3c19d2
parentsixel: unhook: do overwrite *after* linefeeding (diff)
sixel: reflow: drop sixels that crosses the scrollback history’s end
This fixes various crashes that occurred after a reflow due to the sixel image list invariants no longer being true.
-rw-r--r--sixel.c23
1 files changed, 23 insertions, 0 deletions
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(