cvs: php-src /ext/standard array.c /ext/standard/tests/array bug35014.phpt

From: Date: Sun, 30 Oct 2005 13:46:35 +0000
Subject: cvs: php-src /ext/standard array.c /ext/standard/tests/array bug35014.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-34886@lists.php.net to get a copy of this message
iliaa Sun Oct 30 08:46:35 2005 EDT Modified files: /php-src/ext/standard/tests/array bug35014.phpt /php-src/ext/standard array.c Log: MFB51: Fixed bug #35014 (array_product() always returns 0). http://cvs.php.net/diff.php/php-src/ext/standard/tests/array/bug35014.phpt?r1=1.1&r2=1.2&ty=u Index: php-src/ext/standard/tests/array/bug35014.phpt diff -u /dev/null php-src/ext/standard/tests/array/bug35014.phpt:1.2 --- /dev/null Sun Oct 30 08:46:35 2005 +++ php-src/ext/standard/tests/array/bug35014.phpt Sun Oct 30 08:46:34 2005 @@ -0,0 +1,31 @@ +--TEST-- +Bug #35014 (array_product() always returns 0) +--FILE-- +<?php +$tests = array( + 'foo', + array(), + array(0), + array(3), + array(3, 3), + array(0.5, 2), + array(99999999, 99999999), + array(8.993, 7443241,988, sprintf("%u", -1)+0.44), + array(2,sprintf("%u", -1)), +); + +foreach ($tests as $v) { + var_dump(array_product($v)); +} +?> +--EXPECTF-- +Warning: array_product(): The argument should be an array in %s/bug35014.php on line 15 +NULL +int(0) +int(0) +int(3) +int(9) +float(1) +float(9.9999998E+15) +float(2.8404260053903E+20) +float(8589934590) http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.331&r2=1.332&ty=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.331 php-src/ext/standard/array.c:1.332 --- php-src/ext/standard/array.c:1.331 Fri Oct 28 05:57:50 2005 +++ php-src/ext/standard/array.c Sun Oct 30 08:46:34 2005 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c,v 1.331 2005/10/28 09:57:50 dmitry Exp $ */ +/* $Id: array.c,v 1.332 2005/10/30 13:46:34 iliaa Exp $ */ #include "php.h" #include "php_ini.h" @@ -4244,7 +4244,10 @@ return; } - ZVAL_LONG(return_value, 0); + if (!zend_hash_num_elements(Z_ARRVAL_PP(input))) { + RETURN_LONG(0); + } + ZVAL_LONG(return_value, 1); for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(input), &pos); zend_hash_get_current_data_ex(Z_ARRVAL_PP(input), (void **)&entry, &pos) == SUCCESS;

« previous php.cvs (#34886) next »