This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Allow PADTMPs’ strings to be swiped
[perl5.git] / pp_ctl.c
index 7d38bb2..c06e796 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3810,6 +3810,7 @@ PP(pp_require)
        if (vms_unixname)
 #endif
        {
+           SV *nsv = sv;
            namesv = newSV_type(SVt_PV);
            for (i = 0; i <= AvFILL(ar); i++) {
                SV * const dirsv = *av_fetch(ar, i, TRUE);
@@ -3834,11 +3835,15 @@ PP(pp_require)
 
                    ENTER_with_name("call_INC");
                    SAVETMPS;
+                   if (SvPADTMP(nsv)) {
+                       nsv = sv_newmortal();
+                       SvSetSV_nosteal(nsv,sv);
+                   }
                    EXTEND(SP, 2);
 
                    PUSHMARK(SP);
                    PUSHs(dirsv);
-                   PUSHs(sv);
+                   PUSHs(nsv);
                    PUTBACK;
                    if (sv_isobject(loader))
                        count = call_method("INC", G_ARRAY);