Skip to content

Commit b2b95e4

Browse files
author
Father Chrysostomos
committed
Stop localised ties from becoming ro when COW
1 parent fb2352e commit b2b95e4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

mg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ Perl_mg_localize(pTHX_ SV *sv, SV *nsv, bool setmagic)
536536
mg->mg_ptr, mg->mg_len);
537537

538538
/* container types should remain read-only across localization */
539-
SvFLAGS(nsv) |= SvREADONLY(sv);
539+
if (!SvIsCOW(sv)) SvFLAGS(nsv) |= SvREADONLY(sv);
540540
}
541541

542542
if (SvTYPE(nsv) >= SVt_PVMG && SvMAGIC(nsv)) {

t/op/tie.t

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,3 +1014,19 @@ print "ok\n";
10141014
10151015
EXPECT
10161016
ok
1017+
########
1018+
#
1019+
# Localising a tied COW scalar should not make it read-only.
1020+
1021+
sub TIESCALAR { bless [] }
1022+
sub FETCH { __PACKAGE__ }
1023+
sub STORE {}
1024+
tie $x, "";
1025+
"$x";
1026+
{
1027+
local $x;
1028+
$x = 3;
1029+
}
1030+
print "ok\n";
1031+
EXPECT
1032+
ok

0 commit comments

Comments
 (0)