Fix for bug #22367.

Heads up - this will break syntactical compatiblity, return($foo) will
not work with functions that return references - return $foo should be used
instead.  It never worked well before, and caused all sorts of odd bugs.
It *might* be possible to support this specifically, albeit unlikely
This commit is contained in:
Zeev Suraski 2003-07-02 15:06:10 +00:00
parent 92e9e0ca7e
commit d245c52e0c

View File

@ -2748,6 +2748,11 @@ int zend_return_handler(ZEND_OPCODE_HANDLER_ARGS)
zend_error(E_ERROR, "Cannot return overloaded elements or string offsets by reference");
}
if (!(*retval_ptr_ptr)->is_ref
&& EX_T(EX(opline)->op1.u.var).var.ptr_ptr == &EX_T(EX(opline)->op1.u.var).var.ptr) {
zend_error(E_ERROR, "Only variables or references can be returned by reference");
}
SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr);
(*retval_ptr_ptr)->refcount++;