summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/standard/array.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 5827872e49..f9b2eedbbf 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -1067,7 +1067,7 @@ static int php_array_walk(HashTable *target_hash, zval **userdata, int recursive
SEPARATE_ZVAL_TO_MAKE_IS_REF(args[0]);
thash = HASH_OF(*(args[0]));
- if (thash == target_hash) {
+ if (thash->nApplyCount > 1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected");
return 0;
}
@@ -1076,7 +1076,9 @@ static int php_array_walk(HashTable *target_hash, zval **userdata, int recursive
orig_array_walk_fci = BG(array_walk_fci);
orig_array_walk_fci_cache = BG(array_walk_fci_cache);
+ thash->nApplyCount++;
php_array_walk(thash, userdata, recursive TSRMLS_CC);
+ thash->nApplyCount--;
/* restore the fcall info and cache */
BG(array_walk_fci) = orig_array_walk_fci;