From 98f38a4b805d9baf66c914f0f0e279b35045e201 Mon Sep 17 00:00:00 2001 From: Altai-man Date: Tue, 6 Jul 2021 16:28:27 +0200 Subject: [PATCH 1/2] Add a test ensuring a Hash iterator misuse is not exploding --- t/nqp/108-vmhash.t | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/t/nqp/108-vmhash.t b/t/nqp/108-vmhash.t index f346527bc8..0fceb0766e 100644 --- a/t/nqp/108-vmhash.t +++ b/t/nqp/108-vmhash.t @@ -1,4 +1,4 @@ -plan(54); +plan(55); my $backend := nqp::getcomp('nqp').backend.name; @@ -234,3 +234,16 @@ todo('Exceptions for iterators NYI on js', 2) if $backend eq 'js'; ok($msg ne "", 'iterator throws after end'); is($msg, 'Iteration past end of iterator', 'iterator throws correct exception after end'); + +$msg := ""; +try { + my $h := nqp::hash("a", 42); + my $i := nqp::iterator($h); + nqp::deletekey($h, "a"); + nqp::shift($i); + CATCH { + $msg := nqp::getmessage($_); + } +} + +ok($msg eq "", 'No SEGV on a misused hash iterator'); From fa10274ccdb20a28c86c5d63cf6881abcd016b9f Mon Sep 17 00:00:00 2001 From: ab5tract Date: Thu, 16 May 2024 03:05:37 +0200 Subject: [PATCH 2/2] Clarify test message --- t/nqp/108-vmhash.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/nqp/108-vmhash.t b/t/nqp/108-vmhash.t index 0fceb0766e..7d49a02e32 100644 --- a/t/nqp/108-vmhash.t +++ b/t/nqp/108-vmhash.t @@ -246,4 +246,4 @@ try { } } -ok($msg eq "", 'No SEGV on a misused hash iterator'); +ok($msg eq "", 'No SEGV or exception as a result of a misused hash iterator');