summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-12-28 09:36:16 +0000
committerNicholas Clark <nick@ccl4.org>2008-12-28 09:36:16 +0000
commit527df579b2667fd0b8db4c07bcab268e0f401be9 (patch)
tree4b3ce9cb56db5e1c69dbb3b321b8b9fc4c6b2e6e /hv.c
parenta44093a96fbebc6fd778dfaa82b165e9006382a8 (diff)
downloadperl-527df579b2667fd0b8db4c07bcab268e0f401be9.tar.gz
Precomputing the hash value for a string representable in bytes, but passed in
in UTF-8, would result in storing the wrong hash value in the hash, and hence failing lookups. I guess not that much XS code precomputes hash values.
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/hv.c b/hv.c
index 78a1097250..b764c5593e 100644
--- a/hv.c
+++ b/hv.c
@@ -606,6 +606,11 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
if (flags & HVhek_FREEKEY)
Safefree(keysave);
flags |= HVhek_WASUTF8 | HVhek_FREEKEY;
+ /* If the caller calculated a hash, it was on the sequence of
+ octets that are the UTF-8 form. We've now changed the sequence
+ of octets stored to that of the equivalent byte representation,
+ so the hash we need is different. */
+ hash = 0;
}
}