diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-10-04 12:05:37 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-10-09 05:44:17 +0000 |
| commit | 675f3e56c82524cf45526d6856c906133f341c25 (patch) | |
| tree | eb32862f3d221002dc01e2a7c137b4da9f2429fc | |
| parent | sixel: scroll: call sixel_erase() instead of sixel_destroy() (diff) | |
sixel: overwrite-by-rectangle: assert sixels don’t cross scrollback wrap-around
| -rw-r--r-- | sixel.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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 */ |
