changeset 1948:5790b52c339e

Check that we have a CMAP/palette for IFF images that should have it.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 29 Jun 2018 19:32:50 +0300
parents 8896d5676f1b
children f8e2728c1b7f
files tools/libgfx.c
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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)
         {