]> granicus.if.org Git - php/commitdiff
Fixed bug #24980 (array_reduce() uses first element as default running
authorIlia Alshanetsky <iliaa@php.net>
Fri, 8 Aug 2003 23:50:36 +0000 (23:50 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Fri, 8 Aug 2003 23:50:36 +0000 (23:50 +0000)
total).
Fixed memory leak that can be replicated using the function example on
http://www.php.net/array_reduce

ext/standard/array.c

index 8020d468b11a568d089c5416bd5f80eacf522793..e396a2cd846eb6f33016ff8a30fb3ec408dd42e1 100644 (file)
@@ -3374,7 +3374,9 @@ PHP_FUNCTION(array_reduce)
 
        if (ZEND_NUM_ARGS() > 2) {
                result = *initial;
-               zval_add_ref(&result);
+       } else {
+               MAKE_STD_ZVAL(result);
+               ZVAL_LONG(result, 0);
        }
 
        /* (zval **)input points to an element of argument stack