This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
newCONSTSUB needs to be robust in case CopFILE is NULL.
authorNicholas Clark <nick@ccl4.org>
Wed, 19 Apr 2006 11:20:08 +0000 (11:20 +0000)
committerNicholas Clark <nick@ccl4.org>
Wed, 19 Apr 2006 11:20:08 +0000 (11:20 +0000)
p4raw-id: //depot/perl@27901

op.c

diff --git a/op.c b/op.c
index 8efe3b2..ec4cb3a 100644 (file)
--- a/op.c
+++ b/op.c
@@ -5399,13 +5399,13 @@ Perl_newCONSTSUB(pTHX_ HV *stash, const char *name, SV *sv)
     CV* cv;
 #ifdef USE_ITHREADS
     const char *const temp_p = CopFILE(PL_curcop);
-    const STRLEN len = strlen(temp_p);
+    const STRLEN len = temp_p ? strlen(temp_p) : 0;
 #else
     SV *const temp_sv = CopFILESV(PL_curcop);
     STRLEN len;
     const char *const temp_p = temp_sv ? SvPV_const(temp_sv, len) : NULL;
 #endif
-    char *const file = temp_p ? savepvn(temp_p, len) : NULL;
+    char *const file = savepvn(temp_p, temp_p ? len : 0);
 
     ENTER;