aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-03-06 20:37:16 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-03-11 16:32:56 +0000
commit839b7dd32e13c7cae260007cd061a47209674994 (patch)
tree821e687292b279d6af9964d820f2155cee956663
parentsixel: unhook: make sure image height is within bounds (diff)
sixel: resize: don’t resize beyond the current max geometry
-rw-r--r--sixel.c14
1 files changed, 14 insertions, 0 deletions
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) {