From 41e701ad8408a3411bb59198a067c4ef471abba8 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 24 Aug 2026 15:27:25 +0100 Subject: [PATCH] Return early if image is zero height when generating fallback, otherwise we can allocated too little space. Reported by Vivek Parikh. --- image.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/image.c b/image.c index f0543dc4f..5613cf920 100644 --- a/image.c +++ b/image.c @@ -84,6 +84,11 @@ image_fallback(char **ret, u_int sx, u_int sy) char *buf, *label; u_int py, size, lsize; + if (sy == 0) { + *ret = xstrdup(""); + return; + } + /* Allocate first line. */ lsize = xasprintf(&label, "SIXEL IMAGE (%ux%u)\r\n", sx, sy) + 1; if (sx < lsize - 3)