[ID 20020704.001] again: #17678 caused test failures in pod2html,
Hugo van der Sanden [Sun, 4 Aug 2002 23:40:22 +0000 (23:40 +0000)]
in which $1 could leak from previous regexp

p4raw-id: //depot/perl@17679

mg.c

diff --git a/mg.c b/mg.c
index a3ce4c5..1c7d239 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -698,19 +698,20 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
                        SvUTF8_on(sv);
                    else
                        SvUTF8_off(sv);
-                   if (PL_tainting)
-                       PL_tainted = PL_tainted || !!RX_MATCH_TAINTED(rx);
-                   if (RX_MATCH_TAINTED(rx)) {
-                       MAGIC* mg = SvMAGIC(sv);
-                       MAGIC* mgt;
-                       SvMAGIC(sv) = mg->mg_moremagic;
-                       SvTAINT(sv);
-                       if ((mgt = SvMAGIC(sv))) {
-                           mg->mg_moremagic = mgt;
-                           SvMAGIC(sv) = mg;
-                       }
-                   } else
-                       SvTAINTED_off(sv);
+                   if (PL_tainting) {
+                       if (RX_MATCH_TAINTED(rx)) {
+                           MAGIC* mg = SvMAGIC(sv);
+                           MAGIC* mgt;
+                           PL_tainted = 1;
+                           SvMAGIC(sv) = mg->mg_moremagic;
+                           SvTAINT(sv);
+                           if ((mgt = SvMAGIC(sv))) {
+                               mg->mg_moremagic = mgt;
+                               SvMAGIC(sv) = mg;
+                           }
+                       } else
+                           SvTAINTED_off(sv);
+                   }
                    break;
                }
            }