Fix file-descriptor leak when pipes fail via taint checks:
[p5sagit/p5-mst-13.2.git] / sv.h
diff --git a/sv.h b/sv.h
index 42a6a1b..5993a8d 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -246,7 +246,7 @@ struct xpvfm {
     CV *       xcv_outside;
 #ifdef USE_THREADS
     perl_mutex *xcv_mutexp;    /* protects xcv_owner */
-    struct thread *xcv_owner;  /* current owner thread */
+    struct perl_thread *xcv_owner;     /* current owner thread */
 #endif /* USE_THREADS */
     cv_flags_t xcv_flags;
 
@@ -490,7 +490,14 @@ struct xpvio {
 #define SvTAINTED_on(sv)  STMT_START{ if(tainting){sv_taint(sv);}   }STMT_END
 #define SvTAINTED_off(sv) STMT_START{ if(tainting){sv_untaint(sv);} }STMT_END
 
-#define SvTAINT(sv)      STMT_START{ if(tainted){SvTAINTED_on(sv);} }STMT_END
+#define SvTAINT(sv)                    \
+    STMT_START {                       \
+       if (tainting) {                 \
+           dTHR;                       \
+           if (tainted)                \
+               SvTAINTED_on(sv);       \
+       }                               \
+    } STMT_END
 
 #define SvPV_force(sv, lp) sv_pvn_force(sv, &lp)
 #define SvPV(sv, lp) sv_pvn(sv, &lp)
@@ -604,23 +611,28 @@ struct xpvio {
 #  endif
 #endif /* __GNUC__ */
 
-/* the following macro updates any magic values this sv is associated with */
+/* the following macros update any magic values this sv is associated with */
 
-#define SvSETMAGIC(x) if (SvSMAGICAL(x)) mg_set(x)
+#define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END
+#define SvSETMAGIC(x) STMT_START { if (SvSMAGICAL(x)) mg_set(x); } STMT_END
 
 #define SvSetSV_and(dst,src,finally) \
+       STMT_START {                                    \
            if ((dst) != (src)) {                       \
                sv_setsv(dst, src);                     \
                finally;                                \
-           }
+           }                                           \
+       } STMT_END
 #define SvSetSV_nosteal_and(dst,src,finally) \
+       STMT_START {                                    \
            if ((dst) != (src)) {                       \
                U32 tMpF = SvFLAGS(src) & SVs_TEMP;     \
                SvTEMP_off(src);                        \
                sv_setsv(dst, src);                     \
                SvFLAGS(src) |= tMpF;                   \
                finally;                                \
-           }
+           }                                           \
+       } STMT_END
 
 #define SvSetSV(dst,src) \
                SvSetSV_and(dst,src,/*nothing*/;)