diff options
Diffstat (limited to 'filter/image-pnm.c')
-rw-r--r-- | filter/image-pnm.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/filter/image-pnm.c b/filter/image-pnm.c index 1f87829d3..86615d917 100644 --- a/filter/image-pnm.c +++ b/filter/image-pnm.c @@ -3,7 +3,7 @@ * * 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 @@ -67,7 +67,13 @@ _cupsImageReadPNM( * 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); @@ -147,8 +153,21 @@ _cupsImageReadPNM( 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... |