pajoye          Sun Oct  8 17:42:55 2006 UTC

  Modified files:              
    /php-src/ext/gd     gd_ctx.c 
    /php-src/ext/gd/tests       bug39082.phpt 
  Log:
  - MFB: #39082, image* segfaults when used with only one argument
   (introduced in 5.2+, no news entry)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/gd_ctx.c?r1=1.30&r2=1.31&diff_format=u
Index: php-src/ext/gd/gd_ctx.c
diff -u php-src/ext/gd/gd_ctx.c:1.30 php-src/ext/gd/gd_ctx.c:1.31
--- php-src/ext/gd/gd_ctx.c:1.30        Tue Aug  1 22:41:33 2006
+++ php-src/ext/gd/gd_ctx.c     Sun Oct  8 17:42:55 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: gd_ctx.c,v 1.30 2006/08/01 22:41:33 tony2001 Exp $ */
+/* $Id: gd_ctx.c,v 1.31 2006/10/08 17:42:55 pajoye Exp $ */
 
 #include "php_gd.h"
 
@@ -74,7 +74,9 @@
        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);
@@ -86,8 +88,7 @@
                }
        }
 
-       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");
 
                fp = VCWD_FOPEN(fn, "wb");
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/bug39082.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/gd/tests/bug39082.phpt
diff -u /dev/null php-src/ext/gd/tests/bug39082.phpt:1.2
--- /dev/null   Sun Oct  8 17:42:55 2006
+++ php-src/ext/gd/tests/bug39082.phpt  Sun Oct  8 17:42:55 2006
@@ -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

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to