summaryrefslogtreecommitdiff
path: root/ext/standard/array.c
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2007-10-02 10:06:15 +0000
committerAntony Dovgal <tony2001@php.net>2007-10-02 10:06:15 +0000
commitb50ed5df9cd06481837359e62ec53ba82d9b9546 (patch)
tree16e2d39afa91f4619aae824c0f9acbf9f45b4366 /ext/standard/array.c
parentae9a00a64179f566b38c8f00df0c1920f33791e9 (diff)
downloadphp-git-b50ed5df9cd06481837359e62ec53ba82d9b9546.tar.gz
MF5_2: improved recursion detection in array_walk()
fixes #42752, though the leaks are still there
Diffstat (limited to 'ext/standard/array.c')
-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;