hv_ename_delete should not delete the HvNAME
authorFather Chrysostomos <sprout@cpan.org>
Fri, 29 Oct 2010 05:22:10 +0000 (22:22 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 29 Oct 2010 12:42:37 +0000 (05:42 -0700)
This is something that 78b79c7758 missed.

When xhv_name is a HEK *, it is both the regular name and the effect-
ive name at the same time. Only when xhv_name_count is negative is the
regular name not also the effective name.

hv_ename_delete needs to take the HEK that xhv_name points to and
put it in a new HEK * array in xhv_name. This array will just have
one element.

When xhv_name_count is negative, effective names start with the second
element. So we set xhv_name_count to -1 so there isn’t one.

hv.c

diff --git a/hv.c b/hv.c
index 72793e5..91b8b8c 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -2180,8 +2180,10 @@ Perl_hv_ename_delete(pTHX_ HV *hv, const char *name, U32 len)
         HEK_LEN(aux->xhv_name) == (I32)len
      && memEQ(HEK_KEY(aux->xhv_name), name, len)
     ) {
-       unshare_hek_or_pvn(aux->xhv_name, 0, 0, 0);
-       aux->xhv_name = NULL;
+       const HEK * const namehek = aux->xhv_name;
+       Newxc(aux->xhv_name, 1, HEK *, HEK);
+       *(const HEK **)aux->xhv_name = namehek;
+       aux->xhv_name_count = -1;
     }
 }