From 891e0819f0ed1f3812cf54c9071c7ff38715610c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 7 Mar 2021 11:08:01 +0100 Subject: [PATCH] sixel: resize: check new width/height against max geometry early --- sixel.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sixel.c b/sixel.c index ae05ec45..9b68391c 100644 --- a/sixel.c +++ b/sixel.c @@ -849,15 +849,6 @@ resize(struct terminal *term, int new_width, int new_height) term->sixel.image.width, term->sixel.image.height, new_width, new_height); - uint32_t *old_data = term->sixel.image.data; - const int old_width = term->sixel.image.width; - const int old_height = term->sixel.image.height; - - int alloc_new_width = new_width; - int alloc_new_height = (new_height + 6 - 1) / 6 * 6; - xassert(alloc_new_height >= new_height); - xassert(alloc_new_height - new_height < 6); - if (new_width > term->sixel.max_width) return false; @@ -872,6 +863,15 @@ resize(struct terminal *term, int new_width, int new_height) if (new_height > (term->sixel.max_height + 5) / 6 * 6) return false; + uint32_t *old_data = term->sixel.image.data; + const int old_width = term->sixel.image.width; + const int old_height = term->sixel.image.height; + + int alloc_new_width = new_width; + int alloc_new_height = (new_height + 6 - 1) / 6 * 6; + xassert(alloc_new_height >= new_height); + xassert(alloc_new_height - new_height < 6); + uint32_t *new_data = NULL; if (new_width == old_width) {