Patch bug_51986_5_3 for Arrays related Bug #51986
Patch version 2010-09-29 21:12 UTC
Return to Bug #51986 |
Download this patch
Patch Revisions:
Developer: cataphract@php.net
Index: zend_execute_API.c
===================================================================
--- zend_execute_API.c (revision 303877)
+++ zend_execute_API.c (working copy)
@@ -857,13 +857,6 @@
for (i=0; i<fci->param_count; i++) {
zval *param;
- if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION
- && (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0
- && !ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1)
- && PZVAL_IS_REF(*fci->params[i])) {
- SEPARATE_ZVAL(fci->params[i]);
- }
-
if (ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1)
&& !PZVAL_IS_REF(*fci->params[i])) {
@@ -895,6 +888,22 @@
Z_ADDREF_PP(fci->params[i]);
Z_SET_ISREF_PP(fci->params[i]);
param = *fci->params[i];
+ } else if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION
+ && !ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1)
+ && PZVAL_IS_REF(*fci->params[i])
+ && (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0) {
+ zval *new_zval;
+ ALLOC_ZVAL(new_zval);
+ *new_zval = **fci->params[i];
+ INIT_PZVAL(new_zval);
+ zval_copy_ctor(new_zval);
+ /* bug for bug compatibility with current code;
+ * leaves reference if flag refcount <= 1. The only
+ * fix is that the original zval isn't touched */
+ if (Z_REFCOUNT_PP(fci->params[i]) <= 1) {
+ Z_SET_ISREF_P(new_zval);
+ }
+ param = new_zval;
} else if (*fci->params[i] != &EG(uninitialized_zval)) {
Z_ADDREF_PP(fci->params[i]);
param = *fci->params[i];
|