summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-04-22 22:32:09 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-05-21 16:51:32 -0700
commite33525913afb6ff03f7a9e1f9881fd5ea6982f22 (patch)
treea1d8a854f5d7f8fc42bd43fb00c827944d0754ab /mg.c
parent6d77e8c75fe4eeaaa87223507d2214238206bf19 (diff)
downloadperl-e33525913afb6ff03f7a9e1f9881fd5ea6982f22.tar.gz
[perl #111000] Let hv_store work on hint hashes
Magic attached to hash elements has its key stored differently depend- ing on how it was supplied to hv_common. hv_store passes a string/ length pair to hv_common, while hv_store_ent passes an SV. magic_clearhint wasn’t able to handle string/length pairs, and only worked with SVs, resulting in assertion failures or crashes. This commit fixes magic_clearhint, so that XS code can use hv_store on hint hashes.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/mg.c b/mg.c
index 009456ca79..e202d585d3 100644
--- a/mg.c
+++ b/mg.c
@@ -3355,12 +3355,13 @@ Perl_magic_clearhint(pTHX_ SV *sv, MAGIC *mg)
PERL_ARGS_ASSERT_MAGIC_CLEARHINT;
PERL_UNUSED_ARG(sv);
- assert(mg->mg_len == HEf_SVKEY);
-
PL_hints |= HINT_LOCALIZE_HH;
CopHINTHASH_set(&PL_compiling,
- cophh_delete_sv(CopHINTHASH_get(&PL_compiling),
- MUTABLE_SV(mg->mg_ptr), 0, 0));
+ mg->mg_len == HEf_SVKEY
+ ? cophh_delete_sv(CopHINTHASH_get(&PL_compiling),
+ MUTABLE_SV(mg->mg_ptr), 0, 0)
+ : cophh_delete_pvn(CopHINTHASH_get(&PL_compiling),
+ mg->mg_ptr, mg->mg_len, 0, 0));
return 0;
}