sixel: overwrite-by-rectangle: assert sixels don’t cross scrollback wrap-around

This commit is contained in:
Daniel Eklöf 2020-10-04 14:05:37 +02:00
parent 8168fc19df
commit 675f3e56c8
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

11
sixel.c
View file

@ -372,23 +372,26 @@ _sixel_overwrite_by_rectangle(
const int start = row;
const int end = row + height - 1;
/* We should never generate scrollback wrapping sixels */
assert(end < term->grid->num_rows);
const int scrollback_rel_start = rebase_row(term, start);
tll_foreach(term->grid->sixel_images, it) {
struct sixel *six = &it->item;
const int six_start = six->pos.row;
const int six_end = (six_start + six->rows - 1) & (term->grid->num_rows - 1);
const int six_end = (six_start + six->rows - 1);
const int six_scrollback_rel_end = rebase_row(term, six_end);
/* We should never generate scrollback wrapping sixels */
assert(six_end < term->grid->num_rows);
if (six_scrollback_rel_end < scrollback_rel_start) {
/* All remaining sixels are *before* our rectangle */
break;
}
/* We should never generate scrollback wrapping sixels */
assert(six_end >= six_start);
if ((start <= six_start && end >= six_start) || /* Crosses sixel start boundary */
(start <= six_end && end >= six_end) || /* Crosses sixel end boundary */
(start >= six_start && end <= six_end)) /* Fully within sixel range */