*
* Portable Any Map 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
* max sample
*/
- lineptr = fgets(line, sizeof(line), fp);
+ if ((lineptr = fgets(line, sizeof(line), fp)) == NULL)
+ {
+ fputs("DEBUG: Bad PNM header!\n", stderr);
+ fclose(fp);
+ return (1);
+ }
+
lineptr ++;
format = atoi(lineptr);
cupsImageSetMaxTiles(img, 0);
bpp = cupsImageGetDepth(img);
- in = malloc(img->xsize * 3);
- 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);
+ fclose(fp);
+ free(in);
+ return (1);
+ }
/*
* Read the image file...