This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
A better fix for RT #6006: revert change 29616, which was bogus,
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Sat, 23 Dec 2006 15:38:50 +0000 (15:38 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Sat, 23 Dec 2006 15:38:50 +0000 (15:38 +0000)
and add OP_SCOPE to the list of "dangerous" ops that might appear
on the right side of s///.
However, this fix does not work under taint mode, and op/subst.t
has -T.

p4raw-id: //depot/perl@29617

op.c

diff --git a/op.c b/op.c
index 69db999..626f3e8 100644 (file)
--- a/op.c
+++ b/op.c
@@ -3313,7 +3313,8 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, bool isreg)
        else {
            OP *lastop = NULL;
            for (curop = LINKLIST(repl); curop!=repl; curop = LINKLIST(curop)) {
        else {
            OP *lastop = NULL;
            for (curop = LINKLIST(repl); curop!=repl; curop = LINKLIST(curop)) {
-               if (PL_opargs[curop->op_type] & OA_DANGEROUS) {
+               if (curop->op_type == OP_SCOPE
+                       || (PL_opargs[curop->op_type] & OA_DANGEROUS)) {
                    if (curop->op_type == OP_GV) {
                        GV * const gv = cGVOPx_gv(curop);
                        repl_has_vars = 1;
                    if (curop->op_type == OP_GV) {
                        GV * const gv = cGVOPx_gv(curop);
                        repl_has_vars = 1;
@@ -3332,9 +3333,8 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, bool isreg)
                    else if (curop->op_type == OP_PADSV ||
                             curop->op_type == OP_PADAV ||
                             curop->op_type == OP_PADHV ||
                    else if (curop->op_type == OP_PADSV ||
                             curop->op_type == OP_PADAV ||
                             curop->op_type == OP_PADHV ||
-                            curop->op_type == OP_PADANY ||
-                            curop->op_type == OP_SCOPE /* ${10} */
-                            ) {
+                            curop->op_type == OP_PADANY)
+                   {
                        repl_has_vars = 1;
                    }
                    else if (curop->op_type == OP_PUSHRE)
                        repl_has_vars = 1;
                    }
                    else if (curop->op_type == OP_PUSHRE)
@@ -3346,8 +3346,9 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, bool isreg)
            }
        }
        if (curop == repl
            }
        }
        if (curop == repl
-           && !repl_has_vars
-           && (PM_GETRE(pm) && !PM_GETRE(pm)->extflags & RXf_EVAL_SEEN))
+           && !(repl_has_vars
+                && (!PM_GETRE(pm)
+                    || PM_GETRE(pm)->extflags & RXf_EVAL_SEEN)))
        {
            pm->op_pmflags |= PMf_CONST;        /* const for long enough */
            pm->op_pmpermflags |= PMf_CONST;    /* const for long enough */
        {
            pm->op_pmflags |= PMf_CONST;        /* const for long enough */
            pm->op_pmpermflags |= PMf_CONST;    /* const for long enough */