--- a/src/common-image.c +++ b/src/common-image.c @@ -161,7 +161,11 @@ struct image * load_image(char const * n uint32_t depth = (bpp + 7) / 8; /* Allocate the pixel buffer */ - im->pixels = _caca_alloc2d(im->w, im->h, depth); + /* _caca_alloc2d is internal to libcaca */ + if (im->w == 0 || im->h == 0 || SIZE_MAX / im->w / im->h < depth) + im->pixels = NULL; + else + im->pixels = malloc(im->w * im->h * depth); if (!im->pixels) { caca_file_close(f);