aboutsummaryrefslogtreecommitdiff
path: root/sixel.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2026-06-12 16:00:20 +0000
committerDaniel Eklöf <daniel@ekloef.se>2026-06-12 16:04:18 +0000
commitc9c448e61157cf2798f7c571e0e057273d7c3b22 (patch)
treeabfdab9b75fc711e4c6b992e6925b7ebf657653d /sixel.c
parentadd ayu-dark (diff)
sixel: clamp pan/pad to 5
Pad is always (in real life) 1, and no-one should be setting pan to anything larger than 5 (the largest value possible to set with the sixel init parameters). FWIW, no-one really uses anything but 1 here either. Clamping ensures we don't blow up allocations to something huge, or worse, trigger an overflow that results in a pixel height of 0, causing a division-by-zero. Closes #2371
Diffstat (limited to 'sixel.c')
-rw-r--r--sixel.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sixel.c b/sixel.c
index 187f1348..0c1ccd1b 100644
--- a/sixel.c
+++ b/sixel.c
@@ -1888,8 +1888,8 @@ decgra(struct terminal *term, uint8_t c)
unsigned ph = nparams > 2 ? term->sixel.params[2] : 0;
unsigned pv = nparams > 3 ? term->sixel.params[3] : 0;
- pan = pan > 0 ? pan : 1;
- pad = pad > 0 ? pad : 1;
+ pan = pan > 0 ? min(pan, 5) : 1;
+ pad = pad > 0 ? min(pad, 5) : 1;
if (likely(term->sixel.image.width == 0 &&
term->sixel.image.height == 0))