]> granicus.if.org Git - php/commitdiff
Fixed bug #70006 (cli - function with default arg = STDOUT crash output).
authorXinchen Hui <laruence@php.net>
Tue, 7 Jul 2015 11:21:02 +0000 (19:21 +0800)
committerXinchen Hui <laruence@php.net>
Tue, 7 Jul 2015 11:21:02 +0000 (19:21 +0800)
NEWS
Zend/zend_execute_API.c
sapi/cli/tests/bug70006.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 365f0eefb0ecfb978a97fcbda7b8a527bb6682a3..5de290a5d2aace1ba01568d2d3398d57496c0292 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP                                                                        NEWS
 09 Jul 2015, PHP 7.0.0 Beta 1
 
 - Core:
+  . Fixed bug #70006 (cli - function with default arg = STDOUT crash output).
+    (Laruence)
   . Fixed bug #69521 (Segfault in gc_collect_cycles()).
     (arjen at react dot com, Laruence)
   . Improved zend_string API (Francois Laupretre)
index fc92494a1d5f8342045915be9cf1118124a74613..29d06731e54e887029954bafb7c391f1f04be8db 100644 (file)
@@ -555,11 +555,9 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
                zend_throw_error(zend_ce_error, "Cannot declare self-referencing constant '%s'", Z_STRVAL_P(p));
                return FAILURE;
        } else if (Z_TYPE_P(p) == IS_CONSTANT) {
-               int refcount;
 
                SEPARATE_ZVAL_NOREF(p);
                MARK_CONSTANT_VISITED(p);
-               refcount =  Z_REFCOUNTED_P(p) ? Z_REFCOUNT_P(p) : 1;
                if (Z_CONST_FLAGS_P(p) & IS_CONSTANT_CLASS) {
                        ZEND_ASSERT(EG(current_execute_data));
                        if (inline_change) {
@@ -639,8 +637,6 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_bool inline_change, zend_clas
                        }
                        zval_opt_copy_ctor(p);
                }
-
-               if (Z_REFCOUNTED_P(p)) Z_SET_REFCOUNT_P(p, refcount);
        } else if (Z_TYPE_P(p) == IS_CONSTANT_AST) {
                zval tmp;
 
diff --git a/sapi/cli/tests/bug70006.phpt b/sapi/cli/tests/bug70006.phpt
new file mode 100644 (file)
index 0000000..855c9e1
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+Bug #70006 (cli - function with default arg = STDOUT crash output)
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+
+function foo1($stream = STDOUT)
+{
+  //do nothing
+}
+foo1();
+?>
+okey
+--EXPECT--
+okey