]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - filter/image-sgilib.c
Merge changes from CUPS 1.4svn-r7696.
[thirdparty/cups.git] / filter / image-sgilib.c
index 5401c4a7bfc9e884ee4a99f3fbb519b01333f6c0..58e9204e869eec090f01753e43c3860add2971df 100644 (file)
@@ -1,26 +1,17 @@
 /*
- * "$Id: image-sgilib.c 4741 2005-10-02 04:25:52Z mike $"
+ * "$Id: image-sgilib.c 7221 2008-01-16 22:20:08Z mike $"
  *
  *   SGI image file format library routines for the Common UNIX Printing
  *   System (CUPS).
  *
+ *   Copyright 2007-2008 by Apple Inc.
  *   Copyright 1993-2005 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
- *   property of Easy Software Products and are protected by Federal
- *   copyright law.  Distribution and use rights are outlined in the file
- *   "LICENSE.txt" which should have been included with this file.  If this
- *   file is missing or damaged please contact Easy Software Products
- *   at:
- *
- *       Attn: CUPS Licensing Information
- *       Easy Software Products
- *       44141 Airport View Drive, Suite 204
- *       Hollywood, Maryland 20636 USA
- *
- *       Voice: (301) 373-9600
- *       EMail: cups-info@cups.org
- *         WWW: http://www.cups.org
+ *   property of Apple Inc. and are protected by Federal copyright
+ *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ *   which should have been included with this file.  If this file is
+ *   file is missing or damaged, see the license at "http://www.cups.org/".
  *
  *   This file is subject to the Apple OS-Developed Software exception.
  *
@@ -259,8 +250,20 @@ sgiOpenFile(FILE *file,                    /* I - File to open */
 
           fseek(sgip->file, 512, SEEK_SET);
 
-          sgip->table    = calloc(sgip->zsize, sizeof(long *));
-          sgip->table[0] = calloc(sgip->ysize * sgip->zsize, sizeof(long));
+          if ((sgip->table = calloc(sgip->zsize, sizeof(long *))) == NULL)
+         {
+           free(sgip);
+           return (NULL);
+         }
+
+          if ((sgip->table[0] = calloc(sgip->ysize * sgip->zsize,
+                                      sizeof(long))) == NULL)
+          {
+           free(sgip->table);
+           free(sgip);
+           return (NULL);
+         }
+
           for (i = 1; i < sgip->zsize; i ++)
             sgip->table[i] = sgip->table[0] + i * sgip->ysize;
 
@@ -342,12 +345,39 @@ sgiOpenFile(FILE *file,                   /* I - File to open */
 
               sgip->firstrow = ftell(sgip->file);
               sgip->nextrow  = ftell(sgip->file);
-              sgip->table    = calloc(sgip->zsize, sizeof(long *));
-              sgip->table[0] = calloc(sgip->ysize * sgip->zsize, sizeof(long));
+              if ((sgip->table = calloc(sgip->zsize, sizeof(long *))) == NULL)
+             {
+               free(sgip);
+               return (NULL);
+             }
+
+              if ((sgip->table[0] = calloc(sgip->ysize * sgip->zsize,
+                                          sizeof(long))) == NULL)
+              {
+               free(sgip->table);
+               free(sgip);
+               return (NULL);
+             }
+
               for (i = 1; i < sgip->zsize; i ++)
                sgip->table[i] = sgip->table[0] + i * sgip->ysize;
-              sgip->length    = calloc(sgip->zsize, sizeof(long *));
-              sgip->length[0] = calloc(sgip->ysize * sgip->zsize, sizeof(long));
+
+              if ((sgip->length = calloc(sgip->zsize, sizeof(long *))) == NULL)
+             {
+               free(sgip->table);
+               free(sgip);
+               return (NULL);
+             }
+
+              if ((sgip->length[0] = calloc(sgip->ysize * sgip->zsize,
+                                           sizeof(long))) == NULL)
+              {
+               free(sgip->length);
+               free(sgip->table);
+               free(sgip);
+               return (NULL);
+             }
+
               for (i = 1; i < sgip->zsize; i ++)
                sgip->length[i] = sgip->length[0] + i * sgip->ysize;
               break;
@@ -855,5 +885,5 @@ write_rle16(FILE           *fp,             /* I - File to write to */
 
 
 /*
- * End of "$Id: image-sgilib.c 4741 2005-10-02 04:25:52Z mike $".
+ * End of "$Id: image-sgilib.c 7221 2008-01-16 22:20:08Z mike $".
  */