Skip to content

Instantly share code, notes, and snippets.

@arodland
Created February 2, 2016 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arodland/be002c0abb6e4048eec9 to your computer and use it in GitHub Desktop.
Save arodland/be002c0abb6e4048eec9 to your computer and use it in GitHub Desktop.
diff --git a/ListUtil.xs b/ListUtil.xs
index a7cd20c..daa0c41 100644
--- a/ListUtil.xs
+++ b/ListUtil.xs
@@ -384,7 +384,9 @@ CODE:
for(index = 1 ; index < items ; index++) {
GvSV(PL_defgv) = args[index];
+ SvREFCNT_inc(args[index]);
MULTICALL;
+ SvREFCNT_dec(args[index]);
if(SvTRUEx(*PL_stack_sp)) {
# ifdef PERL_HAS_BAD_MULTICALL_REFCOUNT
if(CvDEPTH(multicall_cv) > 1)
@@ -409,7 +411,9 @@ CODE:
GvSV(PL_defgv) = args[index];
PUSHMARK(SP);
+ SvREFCNT_inc(args[index]);
call_sv((SV*)cv, G_SCALAR);
+ SvREFCNT_dec(args[index]);
if(SvTRUEx(*PL_stack_sp)) {
ST(0) = ST(index);
XSRETURN(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment