Subject: | &reduce('foo', 1)' cause segv |
follow code cause segmentation fault.
perl -e 'use List::Util qw(reduce); warn &reduce('foo', 1)'
List::Util code does not check the return value of sv_2cv.
follow is a patch.
=== Util.xs
==================================================================
--- Util.xs (revision 22200)
+++ Util.xs (local)
@@ -252,6 +252,9 @@
XSRETURN_UNDEF;
}
cv = sv_2cv(block, &stash, &gv, 0);
+ if (cv == Nullcv) {
+ croak("first argument should be coderef");
+ }
PUSH_MULTICALL(cv);
agv = gv_fetchpv("a", TRUE, SVt_PV);
bgv = gv_fetchpv("b", TRUE, SVt_PV);