cvs: gd(GD_2_0) /libgd gd.c /libgd/tests/gdimagecolordeallocate gdimagecolordeallocate.c

[email protected] ("Mattias Bengtsson") Sat, 01 Sep 2007 12:35:00 -0000
Newsgroups php.gd.cvs
Message-ID <cvsmattias1188650100@cvsserver>
mattias		Sat Sep  1 12:35:00 2007 UTC

  Modified files:              (Branch: GD_2_0)
    /gd/libgd	gd.c 
    /gd/libgd/tests/gdimagecolordeallocate	gdimagecolordeallocate.c 
  Log:
  - #112, More checking
  
http://cvs.php.net/viewvc.cgi/gd/libgd/gd.c?r1=1.49.2.21&r2=1.49.2.22&diff_format=u
Index: gd/libgd/gd.c
diff -u gd/libgd/gd.c:1.49.2.21 gd/libgd/gd.c:1.49.2.22
--- gd/libgd/gd.c:1.49.2.21	Fri Aug 31 07:31:03 2007
+++ gd/libgd/gd.c	Sat Sep  1 12:34:59 2007
@@ -1,4 +1,4 @@
-/* $Id: gd.c,v 1.49.2.21 2007/08/31 07:31:03 mattias Exp $ */
+/* $Id: gd.c,v 1.49.2.22 2007/09/01 12:34:59 mattias Exp $ */
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -589,7 +589,7 @@
 
 BGD_DECLARE(void) gdImageColorDeallocate (gdImagePtr im, int color)
 {
-  if (im->trueColor || (color >= gdMaxColors))
+  if (im->trueColor || (color >= gdMaxColors) || (color < 0))
     {
       return;
     }
http://cvs.php.net/viewvc.cgi/gd/libgd/tests/gdimagecolordeallocate/gdimagecolordeallocate.c?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: gd/libgd/tests/gdimagecolordeallocate/gdimagecolordeallocate.c
diff -u gd/libgd/tests/gdimagecolordeallocate/gdimagecolordeallocate.c:1.1.2.1 gd/libgd/tests/gdimagecolordeallocate/gdimagecolordeallocate.c:1.1.2.2
--- gd/libgd/tests/gdimagecolordeallocate/gdimagecolordeallocate.c:1.1.2.1	Fri Aug 31 07:31:03 2007
+++ gd/libgd/tests/gdimagecolordeallocate/gdimagecolordeallocate.c	Sat Sep  1 12:35:00 2007
@@ -17,6 +17,14 @@
 		error = -1;
 	}	
 
+	im->open[-1] = 0;
+
+	gdImageColorDeallocate(im, -1);
+
+	if(im->open[-1] == 1) {
+		error = -1;
+	}
+
 	gdImageDestroy(im);
 
 	return error;