Only allow SvPVX() on SVt_PVIO when IOf_FAKE_DIRP is set.
authorNicholas Clark <nick@ccl4.org>
Mon, 28 Jun 2010 16:14:45 +0000 (17:14 +0100)
committerNicholas Clark <nick@ccl4.org>
Wed, 30 Jun 2010 08:11:17 +0000 (09:11 +0100)
sv.c
sv.h

diff --git a/sv.c b/sv.c
index 9a4a082..3111c75 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -11132,7 +11132,8 @@ S_sv_dup_common(pTHX_ const SV *const sstr, CLONE_PARAMS *const param)
 #endif
 
            if (sv_type != SVt_PVAV && sv_type != SVt_PVHV
-               && !isGV_with_GP(dstr))
+               && !isGV_with_GP(dstr)
+               && !(sv_type == SVt_PVIO && !(IoFLAGS(dstr) & IOf_FAKE_DIRP)))
                Perl_rvpv_dup(aTHX_ dstr, sstr, param);
 
            /* The Copy above means that all the source (unduplicated) pointers
diff --git a/sv.h b/sv.h
index 9c6dfd8..adadab3 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -547,7 +547,8 @@ struct xpvio {
 #define IOf_DIDTOP     8       /* just did top of form */
 #define IOf_UNTAINT    16      /* consider this fp (and its data) "safe" */
 #define IOf_NOLINE     32      /* slurped a pseudo-line from empty file */
-#define IOf_FAKE_DIRP  64      /* xio_dirp is fake (source filters kludge) */
+#define IOf_FAKE_DIRP  64      /* xio_dirp is fake (source filters kludge)
+                                  Also, when this is set, SvPVX() is valid */
 
 /* The following macros define implementation-independent predicates on SVs. */
 
@@ -1043,6 +1044,8 @@ the scalar's value cannot change unless written to.
            assert(SvTYPE(_svpvx) != SVt_PVAV);                         \
            assert(SvTYPE(_svpvx) != SVt_PVHV);                         \
            assert(!isGV_with_GP(_svpvx));                              \
+           assert(!(SvTYPE(_svpvx) == SVt_PVIO                         \
+                    && !(IoFLAGS(_svpvx) & IOf_FAKE_DIRP)));           \
            &((_svpvx)->sv_u.svu_pv);                                   \
         }))
 #    define SvCUR(sv)                                                  \