From 3b3a90112ef66849295d70723ebfbdb534a07bd2 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Tue, 28 Oct 2025 21:23:48 +0000 Subject: [PATCH] Fix handling of zero sized image in img2txt Fixes https://github.com/cacalabs/libcaca/issues/65 --- src/img2txt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/img2txt.c b/src/img2txt.c index b8a2589..70a7446 100644 --- a/src/img2txt.c +++ b/src/img2txt.c @@ -176,6 +176,13 @@ int main(int argc, char **argv) return 1; } + if(!i->w || !i->h) + { + fprintf(stderr, "%s: image %s has invalid dimensions %ldx%ld\n", argv[0], argv[argc-1], i->w, i->h); + caca_free_canvas(cv); + return 1; + } + /* Assume a 6×10 font */ if(!cols && !lines) {