]> granicus.if.org Git - php/commitdiff
Fixed support for references
authorDmitry Stogov <dmitry@zend.com>
Thu, 13 Mar 2014 19:23:20 +0000 (23:23 +0400)
committerDmitry Stogov <dmitry@zend.com>
Thu, 13 Mar 2014 19:23:20 +0000 (23:23 +0400)
ext/standard/array.c

index fb594fbbbe681087d68261344ad179b9fa09e891..936a3fa39be3055a156019890173757457892e33 100644 (file)
@@ -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]);