From 8ec0f15a3443765bda6540de7019ef0fe1e96b8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 6 Mar 2021 21:31:16 +0100 Subject: [PATCH] sixel: unhook: make sure image height is within bounds When we allocate the backing buffer, the number of allocated rows is a multiple of 6. When persisting the image, make sure its height does not exceed the current maximum height. --- sixel.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sixel.c b/sixel.c index 115d2139..eca920de 100644 --- a/sixel.c +++ b/sixel.c @@ -695,6 +695,10 @@ sixel_reflow(struct terminal *term) void sixel_unhook(struct terminal *term) { + /* The internal buffer always as a row number that is a multiple of 6 */ + term->sixel.image.height = min( + term->sixel.image.height, term->sixel.max_height); + int pixel_row_idx = 0; int pixel_rows_left = term->sixel.image.height; const int stride = term->sixel.image.width * sizeof(uint32_t);