From: Ilia Alshanetsky Date: Sun, 30 Oct 2005 13:46:34 +0000 (+0000) Subject: MFB51: Fixed bug #35014 (array_product() always returns 0). X-Git-Tag: RELEASE_2_0_1~108 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1321658d91e0173f6b32b0a745b1741f726a8ede;p=php MFB51: Fixed bug #35014 (array_product() always returns 0). --- diff --git a/ext/standard/array.c b/ext/standard/array.c index a2ef5c21c4..02ea08c006 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -4244,7 +4244,10 @@ PHP_FUNCTION(array_product) 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; diff --git a/ext/standard/tests/array/bug35014.phpt b/ext/standard/tests/array/bug35014.phpt new file mode 100644 index 0000000000..8599a3c7ca --- /dev/null +++ b/ext/standard/tests/array/bug35014.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #35014 (array_product() always returns 0) +--FILE-- + +--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)