Browse Source

MFH: fix #41442 (imagegd2() under output control)

experimental/5.2-WITH_DRCP
Antony Dovgal 19 years ago
parent
commit
083844f847
  1. 1
      NEWS
  2. 16
      ext/gd/gd.c
  3. 37
      ext/gd/tests/bug41442.phpt

1
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

16
ext/gd/gd.c

@ -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);

37
ext/gd/tests/bug41442.phpt

@ -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
Loading…
Cancel
Save