summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-09-22 20:31:19 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-09-22 20:31:19 +0000
commitac117f44706c30c5e23f7295ec8491b4705a1c77 (patch)
tree208668b31fb423d88021aa00a1df467be65526c8 /scope.c
parentb6c835310a005ce2e1187890772df402e7333876 (diff)
downloadperl-ac117f44706c30c5e23f7295ec8491b4705a1c77.tar.gz
When localising a magic value, propagate the readonly flag
only if this scalar has \0 magic or has magic without a 'set' method. (follows change #20479 for bug #23141.) p4raw-link: @20479 on //depot/perl: 33f3c7b8444b48791ad016570a41a23483d750d2 p4raw-id: //depot/perl@21323
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/scope.c b/scope.c
index 33d891e13a..2c2ce3698e 100644
--- a/scope.c
+++ b/scope.c
@@ -199,9 +199,9 @@ S_save_scalar_at(pTHX_ SV **sptr)
sv = *sptr = NEWSV(0,0);
if (SvTYPE(osv) >= SVt_PVMG && SvMAGIC(osv) && SvTYPE(osv) != SVt_PVGV) {
+ MAGIC *mg;
sv_upgrade(sv, SvTYPE(osv));
if (SvGMAGICAL(osv)) {
- MAGIC* mg;
bool oldtainted = PL_tainted;
mg_get(osv); /* note, can croak! */
if (PL_tainting && PL_tainted &&
@@ -214,7 +214,17 @@ S_save_scalar_at(pTHX_ SV **sptr)
PL_tainted = oldtainted;
}
SvMAGIC(sv) = SvMAGIC(osv);
- SvFLAGS(sv) |= SvMAGICAL(osv) | SvREADONLY(osv);
+ /* if it's a special scalar or if it has no 'set' magic,
+ * propagate the SvREADONLY flag. --rgs 20030922 */
+ for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
+ if (SvMAGIC(sv)->mg_type == '\0'
+ || !SvMAGIC(sv)->mg_virtual->svt_set)
+ {
+ SvFLAGS(sv) |= SvREADONLY(osv);
+ break;
+ }
+ }
+ SvFLAGS(sv) |= SvMAGICAL(osv);
/* XXX SvMAGIC() is *shared* between osv and sv. This can
* lead to coredumps when both SVs are destroyed without one
* of their SvMAGIC() slots being NULLed. */