php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch array_walk_recursive.patch for Arrays related Bug #52719

Patch version 2012-01-27 13:06 UTC

Return to Bug #52719 | Download this patch
Patch Revisions:

Developer: nikic@php.net

diff --git a/ext/standard/array.c b/ext/standard/array.c
index dd23c95..142a1dc 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -1050,7 +1050,7 @@ PHP_FUNCTION(max)
 }
 /* }}} */
 
-static int php_array_walk(HashTable *target_hash, zval **userdata, int recursive TSRMLS_DC) /* {{{ */
+static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive TSRMLS_DC) /* {{{ */
 {
 	zval **args[3],			/* Arguments to userland function */
 		  *retval_ptr,		/* Return value - unused */
@@ -1062,9 +1062,9 @@ static int php_array_walk(HashTable *target_hash, zval **userdata, int recursive
 
 	/* Set up known arguments */
 	args[1] = &key;
-	args[2] = userdata;
+	args[2] = &userdata;
 	if (userdata) {
-		Z_ADDREF_PP(userdata);
+		Z_ADDREF_P(userdata);
 	}
 
 	zend_hash_internal_pointer_reset_ex(target_hash, &pos);
@@ -1086,7 +1086,7 @@ static int php_array_walk(HashTable *target_hash, zval **userdata, int recursive
 			if (thash->nApplyCount > 1) {
 				php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected");
 				if (userdata) {
-					zval_ptr_dtor(userdata);
+					zval_ptr_dtor(&userdata);
 				}
 				return 0;
 			}
@@ -1139,7 +1139,7 @@ static int php_array_walk(HashTable *target_hash, zval **userdata, int recursive
 	}
 
 	if (userdata) {
-		zval_ptr_dtor(userdata);
+		zval_ptr_dtor(&userdata);
 	}
 	return 0;
 }
@@ -1163,7 +1163,7 @@ PHP_FUNCTION(array_walk)
 		return;
 	}
 
-	php_array_walk(array, userdata ? &userdata : NULL, 0 TSRMLS_CC);
+	php_array_walk(array, userdata, 0 TSRMLS_CC);
 	BG(array_walk_fci) = orig_array_walk_fci;
 	BG(array_walk_fci_cache) = orig_array_walk_fci_cache;
 	RETURN_TRUE;
@@ -1188,7 +1188,7 @@ PHP_FUNCTION(array_walk_recursive)
 		return;
 	}
 
-	php_array_walk(array, userdata ? &userdata : NULL, 1 TSRMLS_CC);
+	php_array_walk(array, userdata, 1 TSRMLS_CC);
 	BG(array_walk_fci) = orig_array_walk_fci;
 	BG(array_walk_fci_cache) = orig_array_walk_fci_cache;
 	RETURN_TRUE;
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 18:02:13 2014 UTC