Huh. I wonder how nobody's ever noticed that before. It's trivially reproducible with any list of purely integers that includes the number zero; such as the attached test.
Fixed in patch.
--
Paul Evans
diff --git a/ListUtil.xs b/ListUtil.xs
index 504c70e..77f42f8 100644
--- a/ListUtil.xs
+++ b/ListUtil.xs
@@ -212,7 +212,8 @@ CODE:
break;
case ACC_IV:
if(is_product) {
- if(!SvNOK(sv) && SvIOK(sv) && (SvIV(sv) < IV_MAX / retiv)) {
+ if(retiv == 0 ||
+ (!SvNOK(sv) && SvIOK(sv) && (SvIV(sv) < IV_MAX / retiv))) {
retiv *= SvIV(sv);
break;
}
diff --git a/t/product.t b/t/product.t
index c397f82..38c923b 100644
--- a/t/product.t
+++ b/t/product.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 13;
+use Test::More tests => 14;
use List::Util qw(product);
@@ -19,6 +19,9 @@ is( $v, 24, '4 args');
$v = product(-1);
is( $v, -1, 'one -1');
+$v = product(0, 1, 2);
+is( $v, 0, 'first factor zero' );
+
my $x = -3;
$v = product($x, 3);