Skip to content

Commit

Permalink
Assert that SvMAGIC() isn't being called on PVMGs which are using the
Browse files Browse the repository at this point in the history
same union to store the stash for our.

p4raw-id: //depot/perl@28065
  • Loading branch information
nwc10 committed May 2, 2006
1 parent 81a2b3b commit 885ffcb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 4 additions & 6 deletions sv.c
Expand Up @@ -5077,10 +5077,8 @@ Perl_sv_clear(pTHX_ register SV *sv)
}
}
if (type >= SVt_PVMG) {
HV *ourstash;
if ((type == SVt_PVMG || type == SVt_PVGV) &&
(ourstash = OURSTASH(sv))) {
SvREFCNT_dec(ourstash);
if ((type == SVt_PVMG || type == SVt_PVGV) && SvPAD_OUR(sv)) {
SvREFCNT_dec(OURSTASH(sv));
} else if (SvMAGIC(sv))
mg_free(sv);
if (type == SVt_PVMG && SvPAD_TYPED(sv))
Expand Down Expand Up @@ -10042,8 +10040,8 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param)
FIXME - instrument and check that assumption */
if (sv_type >= SVt_PVMG) {
HV *ourstash;
if ((sv_type == SVt_PVMG) && (ourstash = OURSTASH(dstr))) {
OURSTASH_set(dstr, hv_dup_inc(ourstash, param));
if ((sv_type == SVt_PVMG) && SvPAD_OUR(dstr)) {
OURSTASH_set(dstr, hv_dup_inc(OURSTASH(dstr), param));
} else if (SvMAGIC(dstr))
SvMAGIC_set(dstr, mg_dup(SvMAGIC(dstr), param));
if (SvSTASH(dstr))
Expand Down
2 changes: 2 additions & 0 deletions sv.h
Expand Up @@ -1164,6 +1164,8 @@ the scalar's value cannot change unless written to.
# define SvMAGIC(sv) \
(*({ SV *const _svi = (SV *) sv; \
assert(SvTYPE(_svi) >= SVt_PVMG); \
if(SvTYPE(_svi) == SVt_PVMG) \
assert(!SvPAD_OUR(_svi)); \
&(((XPVMG*) SvANY(_svi))->xmg_u.xmg_magic); \
}))
# define SvSTASH(sv) \
Expand Down

0 comments on commit 885ffcb

Please sign in to comment.