From 00d5a26a131b2b91cead7588881fb4b41b6d9392 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Mon, 27 Oct 2025 21:53:54 +0000 Subject: [PATCH] Redefine _caca_alloc2d in src/common-image.c This is an internal function that can not be used in this sample code. Easiest is to duplicate it. Fixes https://github.com/cacalabs/libcaca/issues/67 --- src/common-image.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/common-image.c b/src/common-image.c index 7059bf4..461879a 100644 --- a/src/common-image.c +++ b/src/common-image.c @@ -29,6 +29,14 @@ static unsigned int u32fread(caca_file_t *); static unsigned int u16fread(caca_file_t *); static unsigned int u8fread(caca_file_t *); + +static void *_caca_alloc2d(size_t width, size_t height, size_t elem_size) +{ + if (width == 0 || height == 0 || elem_size == 0 || SIZE_MAX / width / height < elem_size) + return NULL; + return malloc(width * height * elem_size); +} + #endif struct image * load_image(char const * name)