diff options
author | Pierre Joye <pajoye@php.net> | 2006-10-08 17:36:10 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2006-10-08 17:36:10 +0000 |
commit | 895aa7d7f77d748ad846c4dbdac6a233aa6a742c (patch) | |
tree | a416c8da52ec91e499c162c6039ad8012f70fb2a | |
parent | 98b16064b4d597560280d3417649631b0aa3de0e (diff) | |
download | php-git-895aa7d7f77d748ad846c4dbdac6a233aa6a742c.tar.gz |
- #39082, image* segfaults when used with only one argument
(introduced in 5.2+, no news entry)
-rw-r--r-- | ext/gd/gd_ctx.c | 6 | ||||
-rw-r--r-- | ext/gd/tests/bug39082.phpt | 18 |
2 files changed, 22 insertions, 2 deletions
diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c index 480b8e3e57..0069f6c0dc 100644 --- a/ext/gd/gd_ctx.c +++ b/ext/gd/gd_ctx.c @@ -75,7 +75,9 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", phpi_get_le_gd()); if (argc > 1) { - convert_to_string_ex(file); + if (argc >= 2 && Z_TYPE_PP(file) != IS_NULL) { + convert_to_string_ex(file); + } fn = Z_STRVAL_PP(file); if (argc >= 3) { convert_to_long_ex(quality); @@ -87,7 +89,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, } } - if ((argc == 2) || (argc > 2 && Z_STRLEN_PP(file))) { + if (argc > 1 && (Z_TYPE_PP(file) != IS_NULL && ((argc == 2) || (argc > 2 && Z_STRLEN_PP(file))))) { PHP_GD_CHECK_OPEN_BASEDIR(fn, "Invalid filename"); diff --git a/ext/gd/tests/bug39082.phpt b/ext/gd/tests/bug39082.phpt new file mode 100644 index 0000000000..9bbfdb2e38 --- /dev/null +++ b/ext/gd/tests/bug39082.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #39082 (Output image to stdout segfaults). +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available\n"); + } + if (!GD_BUNDLED) { + die('skip external GD libraries may fail'); + } +?> +--FILE-- +<?php +$im = imagecreatetruecolor(1,1); +imagegif($im); +?> +--EXPECTF-- +GIF87a%s |