summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2003-12-14 18:35:15 +0000
committerNicholas Clark <nick@ccl4.org>2003-12-14 18:35:15 +0000
commitdcf933a4be50d8c2632709d99162e1b812424330 (patch)
treea045fc24cc691014722a697577ccc5625d9391d3 /hv.c
parent086cb327289a4871101f072239f753777e628728 (diff)
downloadperl-dcf933a4be50d8c2632709d99162e1b812424330.tar.gz
S_save_hek_flags should honour the "free" flag.
Ought to mask the flag bits that shouldn't be stored. p4raw-id: //depot/perl@21907
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/hv.c b/hv.c
index 78d028065d..ee3891204d 100644
--- a/hv.c
+++ b/hv.c
@@ -80,6 +80,7 @@ S_more_he(pTHX)
STATIC HEK *
S_save_hek_flags(pTHX_ const char *str, I32 len, U32 hash, int flags)
{
+ int flags_masked = flags & HVhek_MASK;
char *k;
register HEK *hek;
@@ -89,7 +90,10 @@ S_save_hek_flags(pTHX_ const char *str, I32 len, U32 hash, int flags)
HEK_KEY(hek)[len] = 0;
HEK_LEN(hek) = len;
HEK_HASH(hek) = hash;
- HEK_FLAGS(hek) = (unsigned char)flags;
+ HEK_FLAGS(hek) = (unsigned char)flags_masked;
+
+ if (flags & HVhek_FREEKEY)
+ Safefree(str);
return hek;
}
@@ -2083,7 +2087,7 @@ S_share_hek_flags(pTHX_ const char *str, I32 len, register U32 hash, int flags)
}
if (!found) {
entry = new_HE();
- HeKEY_hek(entry) = save_hek_flags(str, len, hash, flags);
+ HeKEY_hek(entry) = save_hek_flags(str, len, hash, flags_masked);
HeVAL(entry) = Nullsv;
HeNEXT(entry) = *oentry;
*oentry = entry;