]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - filter/image-bmp.c
Merge changes from CUPS 1.5.1-r9875.
[thirdparty/cups.git] / filter / image-bmp.c
index c4b0db71e773411b932b0b36d781191b6f25ed0f..b93c1c5002a4312537b513deb9d9b3ffe2f0bbd6 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: image-bmp.c 6649 2007-07-11 21:46:42Z mike $"
+ * "$Id: image-bmp.c 7221 2008-01-16 22:20:08Z mike $"
  *
- *   BMP image routines for the Common UNIX Printing System (CUPS).
+ *   BMP image routines for CUPS.
  *
- *   Copyright 2007 by Apple Inc.
+ *   Copyright 2007-2011 by Apple Inc.
  *   Copyright 1993-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -170,6 +170,8 @@ _cupsImageReadBMP(
 
   if (colors_used > 0)
     fread(colormap, colors_used, 4, fp);
+  else
+    memset(colormap, 0, sizeof(colormap));
 
  /*
   * Setup image and buffers...
@@ -179,9 +181,22 @@ _cupsImageReadBMP(
 
   cupsImageSetMaxTiles(img, 0);
 
-  in  = malloc(img->xsize * 3);
   bpp = cupsImageGetDepth(img);
-  out = malloc(img->xsize * bpp);
+
+  if ((in = malloc(img->xsize * 3)) == NULL)
+  {
+    fputs("DEBUG: Unable to allocate memory!\n", stderr);
+    fclose(fp);
+    return (1);
+  }
+
+  if ((out = malloc(img->xsize * bpp)) == NULL)
+  {
+    fputs("DEBUG: Unable to allocate memory!\n", stderr);
+    free(in);
+    fclose(fp);
+    return (1);
+  }
 
  /*
   * Read the image data...
@@ -526,5 +541,5 @@ read_long(FILE *fp)               /* I - File to read from */
 
 
 /*
- * End of "$Id: image-bmp.c 6649 2007-07-11 21:46:42Z mike $".
+ * End of "$Id: image-bmp.c 7221 2008-01-16 22:20:08Z mike $".
  */