aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-03-06 20:18:11 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-03-11 16:32:56 +0000
commite94f1085727c0450563a05154c6485fb7d32ec8f (patch)
tree574c6f6d67db6d993a602daa6ed91d959063b9dd
parentsixel: fixup row is multiple of 6 (diff)
sixel: resize: always round up height to a multiple of 6
Sixels are always a multiple of six.
-rw-r--r--sixel.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/sixel.c b/sixel.c
index d89e7a87..7cc9f63c 100644
--- a/sixel.c
+++ b/sixel.c
@@ -848,10 +848,8 @@ resize(struct terminal *term, int new_width, int new_height)
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);
+ new_height = (new_height + 6 - 1) / 6 * 6;
+ xassert(new_height % 6 == 0);
uint32_t *new_data = NULL;
@@ -859,7 +857,7 @@ resize(struct terminal *term, int new_width, int new_height)
/* Width (and thus stride) is the same, so we can simply
* re-alloc the existing buffer */
- new_data = realloc(old_data, alloc_new_width * alloc_new_height * sizeof(uint32_t));
+ new_data = realloc(old_data, new_width * new_height * sizeof(uint32_t));
if (new_data == NULL) {
LOG_ERRNO("failed to reallocate sixel image buffer");
return false;
@@ -870,7 +868,7 @@ resize(struct terminal *term, int new_width, int new_height)
} else {
/* Width (and thus stride) change - need to allocate a new buffer */
xassert(new_width > old_width);
- new_data = xmalloc(alloc_new_width * alloc_new_height * sizeof(uint32_t));
+ new_data = xmalloc(new_width * new_height * sizeof(uint32_t));
/* Copy old rows, and initialize new columns to background color */
for (int r = 0; r < min(old_height, new_height); r++) {