From 527df579b2667fd0b8db4c07bcab268e0f401be9 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Sun, 28 Dec 2008 09:36:16 +0000 Subject: 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. --- hv.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'hv.c') 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; } } -- cgit v1.2.1