Ensure that public I, N and P flags are off when SvTAINT is called on
Nicholas Clark [Mon, 13 Feb 2006 21:46:13 +0000 (21:46 +0000)]
something that already has taint magic.

p4raw-id: //depot/perl@27176

sv.c

diff --git a/sv.c b/sv.c
index 883ba58..8c18a83 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -4242,8 +4242,13 @@ Perl_sv_magic(pTHX_ register SV *sv, SV *obj, int how, const char *name, I32 nam
            /* sv_magic() refuses to add a magic of the same 'how' as an
               existing one
             */
-           if (how == PERL_MAGIC_taint)
+           if (how == PERL_MAGIC_taint) {
                mg->mg_len |= 1;
+               /* Any scalar which already had taint magic on which someone
+                  (erroneously?) did SvIOK_on() or similar will now be
+                  incorrectly sporting public "OK" flags.  */
+               SvFLAGS(sv) &= ~(SVf_IOK|SVf_NOK|SVf_POK);
+           }
            return;
        }
     }