]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - Magic.xs
Delay destruction of reference return values till the current statement end
[perl/modules/Variable-Magic.git] / Magic.xs
index 9eda482e03a65e3652c7732e63b921a0386b47da..b810d91f9db40a63c90e9a75711a8861a809967f 100644 (file)
--- a/Magic.xs
+++ b/Magic.xs
@@ -1246,11 +1246,18 @@ static int vmg_cb_call(pTHX_ SV *cb, unsigned int flags, SV *sv, ...) {
  svr = POPs;
  if (SvOK(svr))
   ret = (int) SvIV(svr);
+ if (SvROK(svr))
+  SvREFCNT_inc(svr);
+ else
+  svr = NULL;
  PUTBACK;
 
  FREETMPS;
  LEAVE;
 
+ if (svr && !SvTEMP(svr))
+  sv_2mortal(svr);
+
  if (chain) {
   vmg_dispell_guard_new(*chain);
   *chain = NULL;