summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2016-06-29 09:16:51 +0100
committerDavid Mitchell <davem@iabyn.com>2016-07-01 09:35:14 +0100
commit2a1e0dfedad09204e5328c32f1fcf915153a191c (patch)
treef58a6439b2bd9f3c0382a792699666a9e521cae2 /pp_ctl.c
parent06a7bc17ca999c04cd2c36ca6162417b9bc32959 (diff)
downloadperl-2a1e0dfedad09204e5328c32f1fcf915153a191c.tar.gz
cx_popeval(): don't mortalise blk_eval.old_namesv
Currently whenever we pop an eval context used for a require, rather than freeing the SV holding the name of the require, we just mortalise it, since some callers of cx_popeval() need the SV to remain long enough to use it to "undo" %INC and to croak with a message such as ""$name did not return a true value". Now that all those usages have been gathered into one place (S_pop_eval_context_maybe_croak), make that function responsible for mortalising when there's a require error, and make the general-case case of cx_popeval() just decrement the reference count.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 0e31e73f5f..86c83e77bb 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1603,7 +1603,12 @@ S_pop_eval_context_maybe_croak(pTHX_ PERL_CONTEXT *cx, SV *errsv, int action)
CX_LEAVE_SCOPE(cx);
do_croak = action && (CxOLD_OP_TYPE(cx) == OP_REQUIRE);
- namesv = cx->blk_eval.old_namesv;
+ if (do_croak) {
+ /* keep namesv alive after cx_popeval() */
+ namesv = cx->blk_eval.old_namesv;
+ cx->blk_eval.old_namesv = NULL;
+ sv_2mortal(namesv);
+ }
cx_popeval(cx);
cx_popblock(cx);
CX_POP(cx);