cvs: gd /libgd/src gd_tiff.c

[email protected] ("Pierre-Alain Joye") Sun, 07 Oct 2007 17:23:56 -0000
Newsgroups php.gd.cvs
Message-ID <cvspajoye1191777836@cvsserver>
pajoye		Sun Oct  7 17:23:56 2007 UTC

  Modified files:              
    /gd/libgd/src	gd_tiff.c 
  Log:
  - stop if the tiff ctx handler cannot be created
  
  
http://cvs.php.net/viewvc.cgi/gd/libgd/src/gd_tiff.c?r1=1.11&r2=1.12&diff_format=u
Index: gd/libgd/src/gd_tiff.c
diff -u gd/libgd/src/gd_tiff.c:1.11 gd/libgd/src/gd_tiff.c:1.12
--- gd/libgd/src/gd_tiff.c:1.11	Sun Oct  7 16:48:01 2007
+++ gd/libgd/src/gd_tiff.c	Sun Oct  7 17:23:56 2007
@@ -27,7 +27,7 @@
 
    ----------------------------------------------------------------------------
  */
-/* $Id: gd_tiff.c,v 1.11 2007/10/07 16:48:01 pajoye Exp $ */
+/* $Id: gd_tiff.c,v 1.12 2007/10/07 17:23:56 pajoye Exp $ */
 
 #ifdef HAVE_CONFIG_H
 	#include "config.h"
@@ -85,11 +85,19 @@
          tiff (assuming one already exists)
 */
 
-tiff_handle *new_tiff_handle(tiff_handle *t, gdIOCtx *g)
+tiff_handle * new_tiff_handle(gdIOCtx *g)
 {
+	tiff_handle * t;
+
+	if (!g) {
+		fprintf(stderr, "Cannot create a new tiff handle, missing Ctx argument");
+		return NULL;
+	}
+
 	t = (tiff_handle *) gdMalloc(sizeof(tiff_handle));
-	if(!t || !g) {
-		return 0;
+	if (!t) {
+		fprintf(stderr, "Failed to allocate a new tiff handle");
+		return NULL;
 	}
 
 	t->size = 0;
@@ -223,7 +231,11 @@
 	uint16 *colorMapBlue;
 
 	tiff_handle *th;
-	th = new_tiff_handle(th, out);
+
+	th = new_tiff_handle(out);
+	if (!th) {
+		return;
+	}
 	extraSamples[0] = EXTRASAMPLE_ASSOCALPHA;
 
 	/* read in the width/height of gd image */
@@ -772,7 +784,11 @@
 
 	gdImagePtr im = NULL;
 
-	th = new_tiff_handle(th, infile);
+	th = new_tiff_handle(infile);
+	if (!th) {
+		return;
+	}
+
 	tif = TIFFClientOpen("", "rb", th, tiff_readproc,
 										tiff_writeproc,
 										tiff_seekproc,