This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
mess_sv(): access only if PL_curcop is non-null
[perl5.git] / util.c
diff --git a/util.c b/util.c
index a542f5e..53b4109 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1518,14 +1518,17 @@ Perl_mess_sv(pTHX_ SV *basemsg, bool consume)
         * from the sibling of PL_curcop.
         */
 
-       const COP *cop =
-           closest_cop(PL_curcop, OpSIBLING(PL_curcop), PL_op, FALSE);
-       if (!cop)
-           cop = PL_curcop;
-
-       if (CopLINE(cop))
-           Perl_sv_catpvf(aTHX_ sv, " at %s line %" IVdf,
-           OutCopFILE(cop), (IV)CopLINE(cop));
+        if (PL_curcop) {
+            const COP *cop =
+                closest_cop(PL_curcop, OpSIBLING(PL_curcop), PL_op, FALSE);
+            if (!cop)
+                cop = PL_curcop;
+
+            if (CopLINE(cop))
+                Perl_sv_catpvf(aTHX_ sv, " at %s line %" IVdf,
+                                OutCopFILE(cop), (IV)CopLINE(cop));
+        }
+
        /* Seems that GvIO() can be untrustworthy during global destruction. */
        if (GvIO(PL_last_in_gv) && (SvTYPE(GvIOp(PL_last_in_gv)) == SVt_PVIO)
                && IoLINES(GvIOp(PL_last_in_gv)))