# HG changeset patch # User Matti Hamalainen # Date 1530289970 -10800 # Node ID 5790b52c339ee29d42a90c5632e4c1104ba1beb6 # Parent 8896d5676f1bdb251f9be47cfff7bcec8fd2969f Check that we have a CMAP/palette for IFF images that should have it. diff -r 8896d5676f1b -r 5790b52c339e tools/libgfx.c --- a/tools/libgfx.c Fri Jun 29 17:17:14 2018 +0300 +++ b/tools/libgfx.c Fri Jun 29 19:32:50 2018 +0300 @@ -1865,9 +1865,16 @@ return res; } - // Set colormap after finishing - if (iff.pal != NULL && iff.ncolors > 0 && *pimg != NULL) + // Check if we should have a palette + if ((*pimg)->format == DM_COLFMT_PALETTE) { + // Check that we DO have a palette .. + if (iff.pal == NULL || iff.ncolors == 0) + { + return dmError(DMERR_INVALID_DATA, + "IFF: A paletted/indexed color image with no CMAP. Bailing out.\n"); + } + // If halfbrite is used, duplicate the palette if (iff.camg & IFF_CAMG_HALFBRITE) {