A safer version of CopFILE, by Jarkko
Rafael Garcia-Suarez [Mon, 23 Apr 2007 13:10:56 +0000 (13:10 +0000)]
p4raw-id: //depot/perl@31032

cop.h

diff --git a/cop.h b/cop.h
index c59a7d6..72cf84c 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -213,7 +213,8 @@ struct cop {
 #  else
 #    define CopFILEAVx(c)      (GvAV(CopFILEGV(c)))
 # endif
-#  define CopFILE(c)           (CopFILESV(c) ? SvPVX(CopFILESV(c)) : NULL)
+#  define CopFILE(c)           (CopFILEGV(c) && GvSV(CopFILEGV(c)) \
+                                   ? SvPVX(GvSV(CopFILEGV(c))) : NULL)
 #  define CopSTASH(c)          ((c)->cop_stash)
 #  define CopLABEL(c)          ((c)->cop_label)
 #  define CopSTASH_set(c,hv)   ((c)->cop_stash = (hv))