From: Nicholas Clark Date: Mon, 4 May 2009 17:53:39 +0000 (+0100) Subject: Make Perl_hek_dup() cope with a NULL "source" parameter (by returning NULL). X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=566771cc1208eb7c5c8363435c4bd1299f0ae5e5;p=p5sagit%2Fp5-mst-13.2.git Make Perl_hek_dup() cope with a NULL "source" parameter (by returning NULL). Change its callers to take advantage of this. --- diff --git a/hv.c b/hv.c index 79f5973..e3dee46 100644 --- a/hv.c +++ b/hv.c @@ -134,11 +134,15 @@ Perl_free_tied_hv_pool(pTHX) HEK * Perl_hek_dup(pTHX_ HEK *source, CLONE_PARAMS* param) { - HEK *shared = (HEK*)ptr_table_fetch(PL_ptr_table, source); + HEK *shared; PERL_ARGS_ASSERT_HEK_DUP; PERL_UNUSED_ARG(param); + if (!source) + return NULL; + + shared = (HEK*)ptr_table_fetch(PL_ptr_table, source); if (shared) { /* We already shared this hash key. */ (void)share_hek_hek(shared); diff --git a/sv.c b/sv.c index b13985b..9d6fddf 100644 --- 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 = gp->gp_file_hek ? hek_dup(gp->gp_file_hek, param) : NULL; + ret->gp_file_hek = hek_dup(gp->gp_file_hek, param); return ret; } @@ -10954,8 +10954,7 @@ Perl_sv_dup(pTHX_ const SV *const sstr, CLONE_PARAMS *const param) LvTARG(dstr) = sv_dup_inc(LvTARG(dstr), param); case SVt_PVGV: if(isGV_with_GP(sstr)) { - if (GvNAME_HEK(dstr)) - GvNAME_HEK(dstr) = hek_dup(GvNAME_HEK(dstr), param); + GvNAME_HEK(dstr) = hek_dup(GvNAME_HEK(dstr), param); /* Don't call sv_add_backref here as it's going to be created as part of the magic cloning of the symbol table. */ @@ -11053,7 +11052,7 @@ Perl_sv_dup(pTHX_ const SV *const sstr, CLONE_PARAMS *const param) SvFLAGS(dstr) |= SVf_OOK; hvname = saux->xhv_name; - daux->xhv_name = hvname ? hek_dup(hvname, param) : hvname; + daux->xhv_name = hek_dup(hvname, param); daux->xhv_riter = saux->xhv_riter; daux->xhv_eiter = saux->xhv_eiter