diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-05-20 23:02:07 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-05-20 23:04:35 +0100 |
commit | 8ac77ac96d51ab94f305d02883edecb1e2a49e19 (patch) | |
tree | e0e128a138b2005da6d58f7a8467e3221e9745fa /mg.c | |
parent | 35df902d513eb29d4fb2b9593ea6aa76507bc590 (diff) | |
download | perl-8ac77ac96d51ab94f305d02883edecb1e2a49e19.tar.gz |
Perl_mg_clear() did not cope with the called magic deleting itself - fix this.
Should all routines that iterate over the magic chain be hardened against this?
Diffstat (limited to 'mg.c')
-rw-r--r-- | mg.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -383,15 +383,18 @@ Perl_mg_clear(pTHX_ SV *sv) { const I32 mgs_ix = SSNEW(sizeof(MGS)); MAGIC* mg; + MAGIC *nextmg; PERL_ARGS_ASSERT_MG_CLEAR; save_magic(mgs_ix, sv); - for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) { + for (mg = SvMAGIC(sv); mg; mg = nextmg) { const MGVTBL* const vtbl = mg->mg_virtual; /* omit GSKIP -- never set here */ + nextmg = mg->mg_moremagic; /* it may delete itself */ + if (vtbl && vtbl->svt_clear) CALL_FPTR(vtbl->svt_clear)(aTHX_ sv, mg); } |