Fix SEGVs when cloning a typeglob that has been undefined. (RT #64954)
Nicholas Clark [Mon, 4 May 2009 17:12:03 +0000 (18:12 +0100)]
sv.c
t/op/threads.t

diff --git a/sv.c b/sv.c
index 7d2eae5..b13985b 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -10505,7 +10505,7 @@ Perl_gp_dup(pTHX_ GP *const gp, CLONE_PARAMS *const param)
     ret->gp_cv         = cv_dup_inc(gp->gp_cv, param);
     ret->gp_cvgen      = gp->gp_cvgen;
     ret->gp_line       = gp->gp_line;
-    ret->gp_file_hek   = hek_dup(gp->gp_file_hek, param);
+    ret->gp_file_hek   = gp->gp_file_hek ? hek_dup(gp->gp_file_hek, param) : NULL;
     return ret;
 }
 
index 814b595..c8ed34a 100644 (file)
@@ -16,7 +16,7 @@ BEGIN {
        exit 0;
      }
 
-     plan(13);
+     plan(14);
 }
 
 use strict;
@@ -185,5 +185,10 @@ threads->new(\&safe_re)->join();
 # tests in threads don't get counted, so
 curr_test(curr_test() + 1);
 
+# This used to crash in 5.10.0 [perl #64954]
+
+undef *a;
+threads->new(sub {})->join;
+pass("undefing a typeglob doesn't cause a crash during cloning");
 
 # EOF