Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19810 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99784 invoked by uid 1010); 29 Oct 2005 07:03:09 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 99769 invoked from network); 29 Oct 2005 07:03:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Oct 2005 07:03:09 -0000 X-Host-Fingerprint: 195.188.213.6 smtp-out3.blueyonder.co.uk Windows 2000 SP2+, XP SP1 (seldom 98 4.10.2222) Received: from ([195.188.213.6:15728] helo=smtp-out3.blueyonder.co.uk) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 7A/08-01249-CAE13634 for ; Sat, 29 Oct 2005 03:03:09 -0400 Received: from [192.168.8.17] ([82.35.45.203]) by smtp-out3.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.6713); Sat, 29 Oct 2005 08:03:55 +0100 To: internals@lists.php.net Date: Sat, 29 Oct 2005 08:03:09 +0100 User-Agent: KMail/1.8.2 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200510290803.09655.arpad@rajeczy.com> X-OriginalArrivalTime: 29 Oct 2005 07:03:55.0888 (UTC) FILETIME=[ED71BF00:01C5DC56] Subject: [PATCH] array_product() From: arpad@rajeczy.com (Arpad Ray) The array_product() function is completely broken. I've filed a bug at http://bugs.php.net/bug.php?id=35014 describing the problem, but to summarise it returns 0 for all valid input and when the input is an empty array. I've also posted a patch, which fixes everything for me. I would appreciate any feedback, especially since this is my first patch :) Thanks, Arpad Ray Index: ext/standard/array.c =================================================================== RCS file: /repository/php-src/ext/standard/array.c,v retrieving revision 1.308.2.10 diff -u -u -b -B -r1.308.2.10 array.c --- ext/standard/array.c 28 Oct 2005 09:57:35 -0000 1.308.2.10 +++ ext/standard/array.c 29 Oct 2005 06:04:22 -0000 @@ -3997,7 +3997,12 @@ return; } - ZVAL_LONG(return_value, 0); + if (zend_hash_num_elements(Z_ARRVAL_PP(input)) == 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array must contain at least one element"); + return; + } + + 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;