Skip to content

Commit e5accad

Browse files
author
Father Chrysostomos
committed
Allow COW values to be deleted from restricted hashes
I wonder how many other things a604c75 broke....
1 parent a130272 commit e5accad

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

dist/base/t/fields.t

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BEGIN {
66
}
77

88
use strict;
9-
use Test::More tests => 16;
9+
use Test::More tests => 17;
1010

1111
BEGIN { use_ok('fields'); }
1212

@@ -106,4 +106,10 @@ package main;
106106
is(ref $x, 'Test::FooBar', 'x is a Test::FooBar');
107107
ok(exists $x->{a}, 'x has a');
108108
ok(exists $x->{b}, 'x has b');
109+
110+
SKIP: {
111+
skip "This test triggers a perl bug", 1 if $] < 5.014001;
112+
$x->{a} = __PACKAGE__;
113+
ok eval { delete $x->{a}; 1 }, 'deleting COW values';
114+
}
109115
}

hv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,8 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
10031003
Safefree(key);
10041004
return NULL;
10051005
}
1006-
if (SvREADONLY(hv) && HeVAL(entry) && SvREADONLY(HeVAL(entry))) {
1006+
if (SvREADONLY(hv) && HeVAL(entry) && SvREADONLY(HeVAL(entry))
1007+
&& !SvIsCOW(HeVAL(entry))) {
10071008
hv_notallowed(k_flags, key, klen,
10081009
"Attempt to delete readonly key '%"SVf"' from"
10091010
" a restricted hash");

0 commit comments

Comments
 (0)