From a583201f15a4d3279f2cd1e47ddd4aea7bf9b6ec Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 11 May 2026 06:34:20 -0400 Subject: [PATCH] check malloc() return in bmp2iff_host.c --- sys/amiga/bmp2iff_host.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/amiga/bmp2iff_host.c b/sys/amiga/bmp2iff_host.c index 154335297..85bb42088 100644 --- a/sys/amiga/bmp2iff_host.c +++ b/sys/amiga/bmp2iff_host.c @@ -409,6 +409,10 @@ main(int argc, char **argv) /* read pixel data */ rowstride = (img_w + 3) & ~3; bmpdata = malloc(rowstride * img_h); + if (!bmpdata) { + printf("%s\n", "malloc failure on bmpdata"); + return 1; + } fseek(bmpfp, fhdr.bfOffBits, SEEK_SET); if (fread(bmpdata, 1, rowstride * img_h, bmpfp) != (size_t)(rowstride * img_h)) { @@ -419,6 +423,10 @@ main(int argc, char **argv) /* flip bottom-up to top-down */ pixels = malloc(img_w * img_h); + if (!pixels) { + printf("%s\n", "malloc failure on pixels"); + return 1; + } if (ihdr.biHeight > 0) { for (y = 0; y < img_h; y++) memcpy(pixels + y * img_w, @@ -441,6 +449,10 @@ main(int argc, char **argv) maxcol, outpal, remap); remapped = malloc(img_w * img_h); + if (!remapped) { + printf("%s\n", "malloc failure on remapped"); + return 1; + } for (i = 0; i < img_w * img_h; i++) remapped[i] = (uint8_t)remap[pixels[i]];