From 3063204289b23203e35de946353585b367066fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 7 Jul 2020 10:42:59 +0200 Subject: [PATCH] sixel: overwrite_by_row: handle case where 'width' goes past end of row Cap 'width' to maximum number of columns available. --- sixel.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sixel.c b/sixel.c index 0a28defd..6072c967 100644 --- a/sixel.c +++ b/sixel.c @@ -367,11 +367,14 @@ sixel_overwrite_by_row(struct terminal *term, int _row, int col, int width) assert(_row >= 0); assert(_row < term->rows); assert(col >= 0); - assert(col + width <= term->grid->num_cols); + assert(col < term->grid->num_cols); if (likely(tll_length(term->grid->sixel_images) == 0)) return; + if (col + width > term->grid->num_cols) + width = term->grid->num_cols - col; + const int row = (term->grid->offset + _row) & (term->grid->num_rows - 1); const int scrollback_rel_row = rebase_row(term, row);