This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp.c:pp_trans: avoid redundant sv in transr
authorFather Chrysostomos <sprout@cpan.org>
Sat, 28 Jul 2012 01:05:02 +0000 (18:05 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 28 Jul 2012 01:07:29 +0000 (18:07 -0700)
I think I added the if (OP_TRANSR) block to the wrong spot, because the
mortal scalar created just before it is only used for y/// without /r.

pp.c

diff --git a/pp.c b/pp.c
index 0def4ac..a57f609 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -676,7 +676,6 @@ PP(pp_trans)
        sv = DEFSV;
        EXTEND(SP,1);
     }
-    TARG = sv_newmortal();
     if(PL_op->op_type == OP_TRANSR) {
        STRLEN len;
        const char * const pv = SvPV(sv,len);
@@ -684,7 +683,10 @@ PP(pp_trans)
        do_trans(newsv);
        PUSHs(newsv);
     }
-    else PUSHi(do_trans(sv));
+    else {
+       TARG = sv_newmortal();
+       PUSHi(do_trans(sv));
+    }
     RETURN;
 }