]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - filter/image-sun.c
Import CUPS 1.4svn-r7226.
[thirdparty/cups.git] / filter / image-sun.c
index 9120d5384b1d2771b8d6e16dbd35ab45ea467f6a..6817ecfeaa73fb0934c88a1bba31e00222eeea40 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Sun Raster image file routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007 by Apple Inc.
+ *   Copyright 2007-2008 by Apple Inc.
  *   Copyright 1993-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -152,9 +152,32 @@ _cupsImageReadSunRaster(
     in = malloc(img->xsize * 3 + 1);
   }
 
-  bpp       = cupsImageGetDepth(img);
-  out       = malloc(img->xsize * bpp);
-  scanline  = malloc(scanwidth);
+  if (!in)
+  {
+    fputs("DEBUG: Unable to allocate memory!\n", stderr);
+    fclose(fp);
+    return (1);
+  }
+
+  bpp = cupsImageGetDepth(img);
+
+  if ((out = malloc(img->xsize * bpp)) == NULL)
+  {
+    fputs("DEBUG: Unable to allocate memory!\n", stderr);
+    fclose(fp);
+    free(in);
+    return (1);
+  }
+
+  if ((scanline = malloc(scanwidth)) == NULL)
+  {
+    fputs("DEBUG: Unable to allocate memory!\n", stderr);
+    fclose(fp);
+    free(in);
+    free(out);
+    return (1);
+  }
+
   run_count = 0;
   run_value = 0;