summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-11-06 21:05:59 +0000
committerNicholas Clark <nick@ccl4.org>2006-11-06 21:05:59 +0000
commit797c717188459bd306f22db4f33d8350f22fec7c (patch)
treebf764cf01bf00700c5b9f545187e33f79fefca8b
parenta0905512454da5aed8153dd1a097bc232ddb6ca9 (diff)
downloadperl-797c717188459bd306f22db4f33d8350f22fec7c.tar.gz
assert() that SvPV_set() isn't used on hashes.
p4raw-id: //depot/perl@29220
-rw-r--r--sv.c8
-rw-r--r--sv.h1
2 files changed, 4 insertions, 5 deletions
diff --git a/sv.c b/sv.c
index eb3796fbe3..8aaa792db3 100644
--- a/sv.c
+++ b/sv.c
@@ -1277,13 +1277,11 @@ Perl_sv_upgrade(pTHX_ register SV *sv, svtype new_type)
assert(SvPVX_const(sv) == 0);
}
- /* Could put this in the else clause below, as PVMG must have SvPVX
- 0 already (the assertion above) */
- SvPV_set(sv, NULL);
-
if (old_type >= SVt_PVMG) {
SvMAGIC_set(sv, ((XPVMG*)old_body)->xmg_u.xmg_magic);
SvSTASH_set(sv, ((XPVMG*)old_body)->xmg_stash);
+ } else {
+ sv->sv_u.svu_array = NULL; /* or svu_hash */
}
break;
@@ -10125,7 +10123,7 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param)
}
}
else
- SvPV_set(dstr, NULL);
+ HvARRAY((HV*)dstr) = NULL;
break;
case SVt_PVCV:
if (!(param->flags & CLONEf_COPY_STACKS)) {
diff --git a/sv.h b/sv.h
index d1b9bb6eb1..0937fbdcc9 100644
--- a/sv.h
+++ b/sv.h
@@ -1239,6 +1239,7 @@ the scalar's value cannot change unless written to.
(((XPVNV*)SvANY(sv))->xnv_u.xnv_nv = (val)); } STMT_END
#define SvPV_set(sv, val) \
STMT_START { assert(SvTYPE(sv) >= SVt_PV); \
+ assert(SvTYPE(sv) != SVt_PVHV); \
assert(!isGV_with_GP(sv)); \
((sv)->sv_u.svu_pv = (val)); } STMT_END
#define SvUV_set(sv, val) \