diff options
author | Andrei Zmievski <andrei@php.net> | 2001-08-07 16:41:33 +0000 |
---|---|---|
committer | Andrei Zmievski <andrei@php.net> | 2001-08-07 16:41:33 +0000 |
commit | 32440e305143cd2af0872b0693bebc77ac6ad80e (patch) | |
tree | a16eed11f7f7979adf000cdef696c73ecbe170c7 /ext/standard/array.c | |
parent | e53100fc7a970b010d0eebf7a513a2b7a1b7ecdd (diff) | |
download | php-git-32440e305143cd2af0872b0693bebc77ac6ad80e.tar.gz |
Fix a couple of leaks.
Diffstat (limited to 'ext/standard/array.c')
-rw-r--r-- | ext/standard/array.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index fd93b76f57..a169e2a2a7 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -2876,8 +2876,10 @@ PHP_FUNCTION(array_reduce) } efree(callback_name); - if (ZEND_NUM_ARGS() > 2) + if (ZEND_NUM_ARGS() > 2) { result = *initial; + zval_add_ref(&result); + } if (zend_hash_num_elements(Z_ARRVAL_PP(input)) == 0) { if (result) { @@ -2893,18 +2895,23 @@ PHP_FUNCTION(array_reduce) args[0] = &result; args[1] = operand; if (call_user_function_ex(EG(function_table), NULL, *callback, &retval, 2, args, 0, NULL TSRMLS_CC) == SUCCESS && retval) { + zval_ptr_dtor(&result); result = retval; } else { php_error(E_WARNING, "%s() had an error invoking the reduction callback", get_active_function_name(TSRMLS_C)); return; } - } else + } else { result = *operand; + zval_add_ref(&result); + } zend_hash_move_forward_ex(Z_ARRVAL_PP(input), &pos); } *return_value = *result; + zval_copy_ctor(return_value); + zval_ptr_dtor(&result); } /* }}} */ |