]> granicus.if.org Git - php/commitdiff
Bug #55754 - Only variables should be passed by reference for ZEND_SEND_PREFER_REF...
authorStanislav Malyshev <stas@php.net>
Sun, 16 Oct 2011 00:34:01 +0000 (00:34 +0000)
committerStanislav Malyshev <stas@php.net>
Sun, 16 Oct 2011 00:34:01 +0000 (00:34 +0000)
Zend/zend_compile.c
tests/lang/bug55754.phpt [new file with mode: 0644]

index f8fe4ef17693ad6d2c3415fb96b329677b4fd09c..a9eb91a9744446dcbcf5cf3f4aaa6c3f8676cec7 100644 (file)
@@ -2487,7 +2487,7 @@ void zend_do_pass_param(znode *param, zend_uchar op, int offset TSRMLS_DC) /* {{
        
        if (function_ptr) {
                if (ARG_MAY_BE_SENT_BY_REF(function_ptr, (zend_uint) offset)) {
-                       if (param->op_type & (IS_VAR|IS_CV)) {
+                       if (param->op_type & (IS_VAR|IS_CV) && original_op != ZEND_SEND_VAL) {
                                send_by_reference = 1;
                                if (op == ZEND_SEND_VAR && zend_is_function_or_method_call(param)) {
                                        /* Method call */
diff --git a/tests/lang/bug55754.phpt b/tests/lang/bug55754.phpt
new file mode 100644 (file)
index 0000000..c58ec91
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Bug #55754 (Only variables should be passed by reference for ZEND_SEND_PREFER_REF params)
+--FILE--
+<?php
+
+current($arr = array(0 => "a"));
+current(array(0 => "a"));
+current($arr);
+
+echo "DONE";
+
+?>
+--EXPECT--
+DONE