From: Nicholas Clark Date: Sun, 14 Dec 2003 18:35:15 +0000 (+0000) Subject: S_save_hek_flags should honour the "free" flag. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dcf933a4be50d8c2632709d99162e1b812424330;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/hv.c b/hv.c index 78d0280..ee38912 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;