summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hv.c2
-rw-r--r--t/op/hash.t11
2 files changed, 11 insertions, 2 deletions
diff --git a/hv.c b/hv.c
index 95df7c8fb4..c8279d87be 100644
--- a/hv.c
+++ b/hv.c
@@ -1450,7 +1450,7 @@ Perl_hv_free_ent(pTHX_ HV *hv, register HE *entry)
if (!entry)
return;
val = HeVAL(entry);
- if (val && isGV(val) && GvCVu(val) && HvNAME_get(hv))
+ if (val && isGV(val) && isGV_with_GP(val) && GvCVu(val) && HvNAME_get(hv))
mro_method_changed_in(hv); /* deletion of method from stash */
SvREFCNT_dec(val);
if (HeKLEN(entry) == HEf_SVKEY) {
diff --git a/t/op/hash.t b/t/op/hash.t
index 6e1b4daa4b..9bde518732 100644
--- a/t/op/hash.t
+++ b/t/op/hash.t
@@ -8,7 +8,7 @@ BEGIN {
use strict;
-plan tests => 5;
+plan tests => 6;
my %h;
@@ -109,3 +109,12 @@ sub hash {
$u += $u << 15; $u %= MASK_U32;
$u;
}
+
+# This will crash perl if it fails
+
+use constant PVBM => 'foo';
+
+my $dummy = index 'foo', PVBM;
+eval { my %h = (a => PVBM); 1 };
+
+ok (!$@, 'fbm scalar can be inserted into a hash');