]> granicus.if.org Git - php/commitdiff
MFH: fix #41442 (imagegd2() under output control)
authorAntony Dovgal <tony2001@php.net>
Tue, 22 May 2007 10:22:49 +0000 (10:22 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 22 May 2007 10:22:49 +0000 (10:22 +0000)
NEWS
ext/gd/gd.c
ext/gd/tests/bug41442.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index b4ac49a8ce655efdc5311b422075b9703d47a82a..7fb9a4c21459ba9ce69c58d4916ae8e4a633c890 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ PHP                                                                        NEWS
 - Fixed segfault in strripos(). (Tony, Joxean Koret)
 - Fixed bug #41455 (ext/dba/config.m4 pollutes global $LIBS and $LDFLAGS). 
   (mmarek at suse dot cz, Tony)
+- Fixed bug #41442 (imagegd2() under output control). (Tony)
 - Fixed bug #41430 (Fatal error with negative values of maxlen parameter of 
   file_get_contents()). (Tony)
 - fixed bug #41423 (PHP assumes wrongly that certain ciphers are enabled in 
index 71bd7b966a4eda0efd27ef160882c46a1eae13e3..3340df08470414bc45b3af378c04f973e6e1846e 100644 (file)
@@ -2825,6 +2825,14 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
                                }
                                (*func_p)(im, fp);
                                break;
+#endif
+#ifdef HAVE_GD_GD2
+                       case PHP_GDIMG_TYPE_GD2:
+                               if (q == -1) {
+                                       q = 128;
+                               }
+                               (*func_p)(im, fp, q, t);
+                               break;
 #endif
                        default:
                                if (q == -1) {
@@ -2877,6 +2885,14 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
                                }
                                (*func_p)(im, tmp);
                                break;
+#endif
+#ifdef HAVE_GD_GD2
+                       case PHP_GDIMG_TYPE_GD2:
+                               if (q == -1) {
+                                       q = 128;
+                               }
+                               (*func_p)(im, tmp, q, t);
+                               break;
 #endif
                        default:
                                (*func_p)(im, tmp);
diff --git a/ext/gd/tests/bug41442.phpt b/ext/gd/tests/bug41442.phpt
new file mode 100644 (file)
index 0000000..78a61be
--- /dev/null
@@ -0,0 +1,37 @@
+--TEST--
+Bug #41442 (imagegd2() under output control)
+--SKIPIF--
+<?php 
+       if (!extension_loaded('gd')) {
+               die("skip gd extension not available.");
+       }
+       if (!function_exists("imagegd2")) {
+               die("skip GD2 support unavailable");
+       }
+?>
+--FILE--
+<?php
+
+$str = file_get_contents(dirname(__FILE__).'/src.gd2');
+$res = imagecreatefromstring($str);
+
+/* string */
+ob_start();
+imagegd2($res);
+$str2 = ob_get_clean();
+var_dump(imagecreatefromstring($str2));
+
+/* file */
+$file = dirname(__FILE__)."/bug41442.gd2";
+imagegd2($res, $file);
+$str2 = file_get_contents($file);
+var_dump(imagecreatefromstring($str2));
+
+@unlink($file);
+
+echo "Done\n";
+?>
+--EXPECTF--    
+resource(%d) of type (gd)
+resource(%d) of type (gd)
+Done