diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2003-09-22 20:31:19 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2003-09-22 20:31:19 +0000 |
commit | ac117f44706c30c5e23f7295ec8491b4705a1c77 (patch) | |
tree | 208668b31fb423d88021aa00a1df467be65526c8 /scope.c | |
parent | b6c835310a005ce2e1187890772df402e7333876 (diff) | |
download | perl-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.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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. */ |