summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2003-05-01 22:06:57 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2003-05-05 15:44:39 +0000
commit2f86008e342644f19f6a5b7136a5027c19cae4c1 (patch)
treeb515e4650a508a22257890194bfb8a1ad47642ff /hv.c
parent462d8b025fb2f0b0f3b03c2b1a0b9a1d4406346c (diff)
downloadperl-2f86008e342644f19f6a5b7136a5027c19cae4c1.tar.gz
[perl #3096] undefing hash with object values
Message-ID: <20030501200657.GA25456@fdgroup.com> p4raw-id: //depot/perl@19424
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/hv.c b/hv.c
index e018a75eb3..f5508bfbcf 100644
--- a/hv.c
+++ b/hv.c
@@ -1728,8 +1728,6 @@ Perl_hv_clear(pTHX_ HV *hv)
}
hfreeentries(hv);
- xhv->xhv_fill = 0; /* HvFILL(hv) = 0 */
- xhv->xhv_keys = 0; /* HvKEYS(hv) = 0 */
xhv->xhv_placeholders = 0; /* HvPLACEHOLDERS(hv) = 0 */
if (xhv->xhv_array /* HvARRAY(hv) */)
(void)memzero(xhv->xhv_array /* HvARRAY(hv) */,
@@ -1758,6 +1756,12 @@ S_hfreeentries(pTHX_ HV *hv)
riter = 0;
max = HvMAX(hv);
array = HvARRAY(hv);
+ /* make everyone else think the array is empty, so that the destructors
+ * called for freed entries can't recusively mess with us */
+ HvARRAY(hv) = Null(HE**);
+ HvFILL(hv) = 0;
+ ((XPVHV*) SvANY(hv))->xhv_keys = 0;
+
entry = array[0];
for (;;) {
if (entry) {
@@ -1771,6 +1775,7 @@ S_hfreeentries(pTHX_ HV *hv)
entry = array[riter];
}
}
+ HvARRAY(hv) = array;
(void)hv_iterinit(hv);
}
@@ -1799,8 +1804,6 @@ Perl_hv_undef(pTHX_ HV *hv)
}
xhv->xhv_max = 7; /* HvMAX(hv) = 7 (it's a normal hash) */
xhv->xhv_array = 0; /* HvARRAY(hv) = 0 */
- xhv->xhv_fill = 0; /* HvFILL(hv) = 0 */
- xhv->xhv_keys = 0; /* HvKEYS(hv) = 0 */
xhv->xhv_placeholders = 0; /* HvPLACEHOLDERS(hv) = 0 */
if (SvRMAGICAL(hv))