summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2004-06-14 15:26:38 +0000
committerNicholas Clark <nick@ccl4.org>2004-06-14 15:26:38 +0000
commitffb05e06c71730527accd4c1399a30e98fb7f6d5 (patch)
tree0466afeb12a6e3fd8429258f0531c202702f6c13 /sv.c
parent5fff27bd847e99d376dc14e8b7fb6503335c47f9 (diff)
downloadperl-ffb05e06c71730527accd4c1399a30e98fb7f6d5.tar.gz
Assert that SV type has magic member when reading/writing.
Will catch buggy code. p4raw-id: //depot/perl@22934
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sv.c b/sv.c
index fe1d406b5d..57ca682cbd 100644
--- a/sv.c
+++ b/sv.c
@@ -1869,6 +1869,9 @@ Perl_sv_upgrade(pTHX_ register SV *sv, U32 mt)
Perl_croak(aTHX_ "Can't upgrade that kind of scalar");
}
+ SvFLAGS(sv) &= ~SVTYPEMASK;
+ SvFLAGS(sv) |= mt;
+
switch (mt) {
case SVt_NULL:
Perl_croak(aTHX_ "Can't upgrade to undef");
@@ -2031,8 +2034,6 @@ Perl_sv_upgrade(pTHX_ register SV *sv, U32 mt)
IoPAGE_LEN(sv) = 60;
break;
}
- SvFLAGS(sv) &= ~SVTYPEMASK;
- SvFLAGS(sv) |= mt;
return TRUE;
}