summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-12-24 07:05:42 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-12-24 16:14:31 -0800
commit746f6409435f8adf48a22fa3c61d95758160b655 (patch)
tree2e01962418518b71f6d2a56e7a5fc25a2662a944 /pp.c
parent3f4d1d7873e4e02f3801f2982565de93d2127bbd (diff)
downloadperl-746f6409435f8adf48a22fa3c61d95758160b655.tar.gz
Don’t crash when writing to null hash elem
It’s possible for XS code to create hash entries with null values. pp_helem and pp_slice were not taking that into account. In fact, the core produces such hash entries, but they are rarely visible from Perl. It’s good to check for them anyway.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/pp.c b/pp.c
index c9d72b8a99..dd67264147 100644
--- a/pp.c
+++ b/pp.c
@@ -4629,7 +4629,7 @@ PP(pp_hslice)
svp = he ? &HeVAL(he) : NULL;
if (lval) {
- if (!svp || *svp == &PL_sv_undef) {
+ if (!svp || !*svp || *svp == &PL_sv_undef) {
DIE(aTHX_ PL_no_helem_sv, SVfARG(keysv));
}
if (localizing) {
@@ -4642,7 +4642,7 @@ PP(pp_hslice)
SAVEHDELETE(hv, keysv);
}
}
- *MARK = svp ? *svp : &PL_sv_undef;
+ *MARK = svp && *svp ? *svp : &PL_sv_undef;
}
if (GIMME != G_ARRAY) {
MARK = ORIGMARK;