sv.c: Allow COWs through sv_magic unscathed
authorFather Chrysostomos <sprout@cpan.org>
Sun, 23 Jun 2013 21:38:32 +0000 (14:38 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 23 Jun 2013 21:38:32 +0000 (14:38 -0700)
There is no need to run COWs through sv_force_normal when
attaching magic to them via sv_magic.  (I don’t know about
PERL_OLD_COPY_ON_WRITE, but I left it in, just to be sure.)

Before this, only sv_magicext could attach magic to SVs that were
already COWs.  That meant pos($cow)=7 would leave it as a COW, but
copy-on-write would never happen with tainted strings.

sv.c

diff --git a/sv.c b/sv.c
index 81db766..cc93089 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -5436,7 +5436,7 @@ Perl_sv_magic(pTHX_ SV *const sv, SV *const obj, const int how,
     vtable = (vtable_index == magic_vtable_max)
        ? NULL : PL_magic_vtables + vtable_index;
 
-#ifdef PERL_ANY_COW
+#ifdef PERL_OLD_COPY_ON_WRITE
     if (SvIsCOW(sv))
         sv_force_normal_flags(sv, 0);
 #endif