This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Restore NULL check to gv.c:newGP, removed by 19bad673
authorFather Chrysostomos <sprout@cpan.org>
Sat, 10 Aug 2013 17:46:43 +0000 (10:46 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 11 Aug 2013 17:53:35 +0000 (10:53 -0700)
1df5f7c195 added checks to newGP to account for PL_curcop being NULL.
19bad673 inadvertently removed the NULL check for non-threaded builds,
except in one spot.

Since S_cop_free now sets PL_curcop to NULL as of the previous commit
(something 1df5f7c195 was meant to do but didn’t), this check is a
good idea, even though PL_curcop is never NULL here.

See also <20130805200313.GS3729@plum.flirble.org>.

gv.c

diff --git a/gv.c b/gv.c
index 869d237..076fafd 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -191,13 +191,17 @@ Perl_newGP(pTHX_ GV *const gv)
        len = 0;
     }
 #else
-    if(PL_curcop)
+    if(PL_curcop) {
        gp->gp_line = CopLINE(PL_curcop); /* 0 otherwise Newxz */
-    filegv = CopFILEGV(PL_curcop);
-    if (filegv) {
-       file = GvNAME(filegv)+2;
-       len = GvNAMELEN(filegv)-2;
-    } else {
+       filegv = CopFILEGV(PL_curcop);
+       if (filegv) {
+           file = GvNAME(filegv)+2;
+           len = GvNAMELEN(filegv)-2;
+       }
+       else goto no_file;
+    }
+    else {
+       no_file:
        file = "";
        len = 0;
     }