summaryrefslogtreecommitdiff
path: root/pp_sort.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2009-12-07 14:58:40 +0100
committerRafael Garcia-Suarez <rgs@consttype.org>2009-12-07 14:58:40 +0100
commit8a27a13e89107aaf68c0748b68ee71fbd86d774b (patch)
tree99c88fba6b802c9c35eedd88257497a085e8a57a /pp_sort.c
parent6bc991bfb3c34a5d286a1202fcc0d740d72dcee7 (diff)
downloadperl-8a27a13e89107aaf68c0748b68ee71fbd86d774b.tar.gz
[perl #71076] sort with active sub (5.10 regression)
One of the tests in sort.t causes a bus error (or sometimes ‘Undefined subroutine called’) if run multiple times. This is because sort decreases the refcount of an active sub used as a comparison routine. Ironically enough, this test was added by the very change that broke it (25953/9850bf2).
Diffstat (limited to 'pp_sort.c')
-rw-r--r--pp_sort.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/pp_sort.c b/pp_sort.c
index a657fa744a..12e77f9445 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1652,6 +1652,11 @@ PP(pp_sort)
if (!(flags & OPf_SPECIAL)) {
cx->cx_type = CXt_SUB;
cx->blk_gimme = G_SCALAR;
+ /* If our comparison routine is already active (CvDEPTH is
+ * is not 0), then PUSHSUB does not increase the refcount,
+ * so we have to do it ourselves, because the LEAVESUB fur-
+ * ther down lowers it. */
+ if (CvDEPTH(cv)) SvREFCNT_inc_simple_void_NN(cv);
PUSHSUB(cx);
if (!is_xsub) {
AV* const padlist = CvPADLIST(cv);