diff options
author | Nicholas Clark <nick@ccl4.org> | 2003-11-16 17:11:22 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2003-11-16 17:11:22 +0000 |
commit | 0314122ad44242ba258780f75ab0eceec9310eb1 (patch) | |
tree | 165881d98a0d2050ce02df9b14bc8376ee00347f /hv.c | |
parent | ad4404a3f856c0fca45d321d6f18a8048b0574a8 (diff) | |
download | perl-0314122ad44242ba258780f75ab0eceec9310eb1.tar.gz |
Accessing unicode keys in tie hashes via hv_exists was broken.
(pp_exists uses hv_exists_ent, which isn't broken)
I expect an equivalent bug in hv_delete
p4raw-id: //depot/perl@21734
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -1276,6 +1276,15 @@ Perl_hv_exists(pTHX_ HV *hv, const char *key, I32 klen) if (SvRMAGICAL(hv)) { if (mg_find((SV*)hv, PERL_MAGIC_tied) || SvGMAGICAL((SV*)hv)) { sv = sv_newmortal(); + if (is_utf8) { + /* This hack based on the code in hv_exists_ent seems to be + the easiest way to pass the utf8 flag through and fix + the bug in hv_exists for tied hashes with utf8 keys. */ + SV *keysv = sv_2mortal(newSVpvn(key, klen)); + SvUTF8_on(keysv); + key = (char *)keysv; + klen = HEf_SVKEY; + } mg_copy((SV*)hv, sv, key, klen); magic_existspack(sv, mg_find(sv, PERL_MAGIC_tiedelem)); return (bool)SvTRUE(sv); |