This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add some paranoia to check that GP accesses aren't being done on the
authorNicholas Clark <nick@ccl4.org>
Sat, 17 Dec 2005 23:22:31 +0000 (23:22 +0000)
committerNicholas Clark <nick@ccl4.org>
Sat, 17 Dec 2005 23:22:31 +0000 (23:22 +0000)
wrong types of SV.

p4raw-id: //depot/perl@26395

gv.h

diff --git a/gv.h b/gv.h
index d9a5b51..f179494 100644 (file)
--- a/gv.h
+++ b/gv.h
@@ -24,7 +24,14 @@ struct gp {
 
 #define GvXPVGV(gv)    ((XPVGV*)SvANY(gv))
 
-#define GvGP(gv)       (GvXPVGV(gv)->xgv_gp)
+#ifdef DEBUGGING
+#  define GvGP(gv)     (*(assert(SvTYPE(gv) == SVt_PVGV || \
+                                 SvTYPE(gv) == SVt_PVLV), \
+                          &(GvXPVGV(gv)->xgv_gp)))
+#else
+#  define GvGP(gv)     (GvXPVGV(gv)->xgv_gp)
+#endif
+
 #define GvNAME(gv)     (GvXPVGV(gv)->xgv_name)
 #define GvNAMELEN(gv)  (GvXPVGV(gv)->xgv_namelen)
 #define GvSTASH(gv)    (GvXPVGV(gv)->xgv_stash)