summaryrefslogtreecommitdiff
path: root/pp_sort.c
diff options
context:
space:
mode:
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);