From: Dmitry Stogov Date: Thu, 13 Mar 2014 19:23:20 +0000 (+0400) Subject: Fixed support for references X-Git-Tag: POST_PHPNG_MERGE~412^2~329 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dd1bd544084d5a5fcfdb804c6ad0237fcfb0a611;p=php Fixed support for references --- diff --git a/ext/standard/array.c b/ext/standard/array.c index fb594fbbbe..936a3fa39b 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1054,13 +1054,19 @@ static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive zend_hash_internal_pointer_reset(target_hash); while (!EG(exception) && (zv = zend_hash_get_current_data(target_hash)) != NULL) { ZVAL_COPY(&args[0], zv); - if (recursive && Z_TYPE(args[0]) == IS_ARRAY) { + if (recursive && + (Z_TYPE(args[0]) == IS_ARRAY || + (Z_ISREF(args[0]) && Z_TYPE_P(Z_REFVAL(args[0])) == IS_ARRAY))) { HashTable *thash; zend_fcall_info orig_array_walk_fci; zend_fcall_info_cache orig_array_walk_fci_cache; - SEPARATE_ZVAL_IF_NOT_REF(&args[0]); - thash = Z_ARRVAL(args[0]); + if (Z_ISREF(args[0])) { + thash = Z_ARRVAL_P(Z_REFVAL(args[0])); + } else { + SEPARATE_ZVAL(&args[0]); + thash = Z_ARRVAL(args[0]); + } if (thash->nApplyCount > 1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected"); zval_ptr_dtor(&args[0]);