From http://www.jwz.org/xscreensaver/xscreensaver-5.30.tar.gz
[xscreensaver] / utils / minixpm.c
index 247eca89efc723ac05c7455e855ffaab1a91c317..13a8ab3ce6cda1a866e3136726e424ae7819daed 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 2001-2006 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 2001-2014 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -121,6 +121,16 @@ minixpm_to_ximage (Display *dpy, Visual *visual, Colormap colormap, int depth,
               r = g = b = -1;
               line += 4;
             }
+          else if (!strncasecmp(line, "white", 5))
+            {
+              r = g = b = 255;
+              line += 5;
+            }
+          else if (!strncasecmp(line, "black", 5))
+            {
+              r = g = b = 0;
+              line += 5;
+            }
           else
             {
               if (*line != '#') {
@@ -190,17 +200,23 @@ minixpm_to_ximage (Display *dpy, Visual *visual, Colormap colormap, int depth,
   ximage = XCreateImage (dpy, visual, depth,
                          (depth == 1 ? XYBitmap : ZPixmap),
                          0, 0, w, h, 8, 0);
-  if (! ximage) return 0;
+  if (! ximage)
+    {
+      if (pixels) free (pixels);
+      return 0;
+    }
 
   ximage->bitmap_bit_order =
     ximage->byte_order =
     (bigendian() ? MSBFirst : LSBFirst);
 
   ximage->data = (char *) calloc (ximage->height, ximage->bytes_per_line);
-  if (!ximage->data) {
-    XDestroyImage (ximage);
-    return 0;
-  }
+  if (!ximage->data)
+    {
+      XDestroyImage (ximage);
+      if (pixels) free (pixels);
+      return 0;
+    }
 
   w8 = (w + 7) / 8;
   if (mask_ret)