From 839b7dd32e13c7cae260007cd061a47209674994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 6 Mar 2021 21:37:16 +0100 Subject: [PATCH] =?UTF-8?q?sixel:=20resize:=20don=E2=80=99t=20resize=20bey?= =?UTF-8?q?ond=20the=20current=20max=20geometry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sixel.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sixel.c b/sixel.c index eca920de..498d18f2 100644 --- a/sixel.c +++ b/sixel.c @@ -855,6 +855,20 @@ resize(struct terminal *term, int new_width, int new_height) new_height = (new_height + 6 - 1) / 6 * 6; xassert(new_height % 6 == 0); + if (new_width > term->sixel.max_width) + return false; + + /* + * Last row may be cropped by the max height, but don’t skip that + * last partial row entirely. + * + * I.e if max height is ‘4’, then allow resizing up to 6, to allow + * us to emit that last sixel row. The final image will be cropped + * to the current max geometry in unhook. + */ + if (new_height > (term->sixel.max_height + 5) / 6 * 6) + return false; + uint32_t *new_data = NULL; if (new_width == old_width) {