summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-01-04 06:05:41 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-01-04 06:06:03 -0800
commit901ee108fe1f8070e4722d8313bf202d0eb843b0 (patch)
tree01871bec19b77e5310c10592d7a76fc35895a84e /pp_ctl.c
parenta76c354d5bbd0beffab91da21869cc5a9ef5ee30 (diff)
downloadperl-901ee108fe1f8070e4722d8313bf202d0eb843b0.tar.gz
[perl #120657] Fix require PADTMP when @INC=(sub{},sub{})
It was passing a freed scalar to subsequent subs, breaking Test::Without::Module: sub fake_module { my (undef,$module_file) = @_; !1 } unshift @INC, (\&fake_module)x2; require "${\'whatever'}"; __END__ panic: attempt to copy freed scalar 7fe8d0829820 to 7fe8d082a0f0 at - line 3. Obviously, doing: SAVETMPS; ... nsv = sv_newmortal(); ... FREETMPS; # free all tmps created since SAVETMPS inside a loop that only assigns to nsv the first time through will cause nsv to point to a freed scalar on subsequent iterations. It was stupid of me to make that mistake in commit 9ffd39a to begin with. The extra file name SV here will simply have to last until the require call finishes, something I was trying to avoid by putting it after SAVETMPS.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index c8c67736b0..7236921455 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3833,12 +3833,13 @@ PP(pp_require)
tryname = SvPVX_const(namesv);
tryrsfp = NULL;
- ENTER_with_name("call_INC");
- SAVETMPS;
if (SvPADTMP(nsv)) {
nsv = sv_newmortal();
SvSetSV_nosteal(nsv,sv);
}
+
+ ENTER_with_name("call_INC");
+ SAVETMPS;
EXTEND(SP, 2);
PUSHMARK(SP);