From be6064fd646b3102eae032226820fb886c52b961 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Tue, 26 Jun 2012 20:21:29 -0700 Subject: [PATCH] =?utf8?q?Null=20HeVAL=20and=20local=20delete=20=E2=86=92?= =?utf8?q?=20crash?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The XS API allows hash entries to be created with null values. perl itself uses these internally, too. Though they should rarely be seen by Perl code, Perl ops should still be able to handle them without crashing (by croaking). I fixed helem and hslice in 5.16 (commit 746f6409), but missed localised deletions. --- ext/XS-APItest/t/hash.t | 4 ++++ pp.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ext/XS-APItest/t/hash.t b/ext/XS-APItest/t/hash.t index 84b6274..9e27af8 100644 --- a/ext/XS-APItest/t/hash.t +++ b/ext/XS-APItest/t/hash.t @@ -258,6 +258,10 @@ sub test_precomputed_hashes { warnings; # thank you! @h{85} = 1 }; pass 'no crash when writing to hash elem with null value via slice'; + eval { delete local $h{86} }; + pass 'no crash during local deletion of hash elem with null value'; + eval { delete local @h{87,88} }; + pass 'no crash during local deletion of hash slice with null values'; } # [perl #111000] Bug number eleventy-one thousand: diff --git a/pp.c b/pp.c index 99ff027..82f7105 100644 --- a/pp.c +++ b/pp.c @@ -4453,6 +4453,7 @@ S_do_delete_local(pTHX) SvREFCNT_inc_simple_void(sv); /* De-mortalize */ } if (preeminent) { + if (!sv) DIE(aTHX_ PL_no_helem_sv, SVfARG(keysv)); save_helem_flags(hv, keysv, &sv, SAVEf_KEEPOLDELEM); if (tied) { *MARK = sv_mortalcopy(sv); @@ -4539,6 +4540,7 @@ S_do_delete_local(pTHX) SvREFCNT_inc_simple_void(sv); /* De-mortalize */ } if (preeminent) { + if (!sv) DIE(aTHX_ PL_no_helem_sv, SVfARG(keysv)); save_helem_flags(hv, keysv, &sv, SAVEf_KEEPOLDELEM); if (tied) { SV *nsv = sv_mortalcopy(sv); -- 2.7.4