diff options
Diffstat (limited to 'ext/standard/array.c')
-rw-r--r-- | ext/standard/array.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index e4156e89d..dd3ed25d9 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c 293982 2010-01-25 14:11:32Z johannes $ */ +/* $Id: array.c 300371 2010-06-11 08:53:31Z dmitry $ */ #include "php.h" #include "php_ini.h" @@ -640,7 +640,7 @@ PHP_FUNCTION(usort) } /* Clear the is_ref flag, so the attemts to modify the array in user - * comaprison function will create a copy of array and won't affect the + * comparison function will create a copy of array and won't affect the * original array. The fact of modification is detected using refcount * comparison. The result of sorting in such case is undefined and the * function returns FALSE. @@ -1057,6 +1057,9 @@ static int php_array_walk(HashTable *target_hash, zval **userdata, int recursive /* Set up known arguments */ args[1] = &key; args[2] = userdata; + if (userdata) { + Z_ADDREF_PP(userdata); + } zend_hash_internal_pointer_reset_ex(target_hash, &pos); @@ -1076,6 +1079,9 @@ static int php_array_walk(HashTable *target_hash, zval **userdata, int recursive thash = Z_ARRVAL_PP(args[0]); if (thash->nApplyCount > 1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected"); + if (userdata) { + zval_ptr_dtor(userdata); + } return 0; } @@ -1126,6 +1132,9 @@ static int php_array_walk(HashTable *target_hash, zval **userdata, int recursive zend_hash_move_forward_ex(target_hash, &pos); } + if (userdata) { + zval_ptr_dtor(userdata); + } return 0; } /* }}} */ |