This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
gv.c:newGP: assert that PL_curcop is not NULL
authorFather Chrysostomos <sprout@cpan.org>
Sat, 10 Aug 2013 18:55:11 +0000 (11:55 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 11 Aug 2013 17:53:35 +0000 (10:53 -0700)
It should never be null here, and we want to know if it is.  (It can
be set to null in op.c:S_cop_free, but it should always have been set
to something else by the time newGP is called.)

Nevertheless, we should leave the null checks in place, to avoid sabo-
taging non-debugging builds if there are any remaining bugs here.

gv.c

diff --git a/gv.c b/gv.c
index f51f782..13bcbbf 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -176,6 +176,9 @@ Perl_newGP(pTHX_ GV *const gv)
     gp->gp_sv = newSV(0);
 #endif
 
+    /* PL_curcop should never be null here. */
+    assert(PL_curcop);
+    /* But for non-debugging builds play it safe */
     if (PL_curcop) {
        gp->gp_line = CopLINE(PL_curcop); /* 0 otherwise Newxz */
 #ifdef USE_ITHREADS