This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
An implementation of change 29735 for blead (PL_curcop could be NULL)
[perl5.git] / gv.c
diff --git a/gv.c b/gv.c
index 9f9b0d3..e4c59b5 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -161,7 +161,8 @@ GP *
 Perl_newGP(pTHX_ GV *const gv)
 {
     GP *gp;
 Perl_newGP(pTHX_ GV *const gv)
 {
     GP *gp;
-    const char *const file = CopFILE(PL_curcop) ? CopFILE(PL_curcop) : "";
+    const char *const file
+       = (PL_curcop && CopFILE(PL_curcop)) ? CopFILE(PL_curcop) : "";
     STRLEN len = strlen(file);
     U32 hash;
 
     STRLEN len = strlen(file);
     U32 hash;
 
@@ -173,7 +174,7 @@ Perl_newGP(pTHX_ GV *const gv)
     gp->gv_sv = newSV(0);
 #endif
 
     gp->gv_sv = newSV(0);
 #endif
 
-    gp->gp_line = CopLINE(PL_curcop);
+    gp->gp_line = PL_curcop ? CopLINE(PL_curcop) : 0;
     /* XXX Ideally this cast would be replaced with a change to const char*
        in the struct.  */
     gp->gp_file_hek = share_hek(file, len, hash);
     /* XXX Ideally this cast would be replaced with a change to const char*
        in the struct.  */
     gp->gp_file_hek = share_hek(file, len, hash);