From b50ed5df9cd06481837359e62ec53ba82d9b9546 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Tue, 2 Oct 2007 10:06:15 +0000 Subject: MF5_2: improved recursion detection in array_walk() fixes #42752, though the leaks are still there --- ext/standard/array.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- cgit v1.2.1