summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-05-02 17:00:56 +0000
committerNicholas Clark <nick@ccl4.org>2006-05-02 17:00:56 +0000
commit885ffcb307023fbe2047bd0c0e016f18bebc1fb3 (patch)
treedc57bea9875ef9e89109be7bfcfb3b9160177e0c
parent81a2b3b63405cdf740520d468d3da237ead91a62 (diff)
downloadperl-885ffcb307023fbe2047bd0c0e016f18bebc1fb3.tar.gz
Assert that SvMAGIC() isn't being called on PVMGs which are using the
same union to store the stash for our. p4raw-id: //depot/perl@28065
-rw-r--r--sv.c10
-rw-r--r--sv.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/sv.c b/sv.c
index 70a5110fbf..1fb948bb26 100644
--- a/sv.c
+++ b/sv.c
@@ -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))
@@ -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))
diff --git a/sv.h b/sv.h
index 71389c9d89..ec6184ba66 100644
--- a/sv.h
+++ b/sv.h
@@ -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) \