From 70d09bcdf2194cdc661aca9e782f9bb9829af33c Mon Sep 17 00:00:00 2001 From: Tim Haines Date: Thu, 5 Dec 2024 10:55:44 -0600 Subject: [PATCH] Fix possible double-free in CFT tests (#240) In the event there are more operands than test results, the test should fail, not crash. --- src/instruction/aarch64_cft.C | 4 +++- src/instruction/power_cft.C | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/instruction/aarch64_cft.C b/src/instruction/aarch64_cft.C index 745f3d82..d7fb26f4 100644 --- a/src/instruction/aarch64_cft.C +++ b/src/instruction/aarch64_cft.C @@ -199,7 +199,9 @@ test_results_t aarch64_cft_Mutator::executeTest() logerror("FAILED: instruction %s expected CFT, wasn't present", decodedInsns.front().format().c_str()); retVal = failure_accumulator(retVal, FAILED); } - cfts.pop_front(); + if(!cfts.empty()) { + cfts.pop_front(); + } } decodedInsns.pop_front(); diff --git a/src/instruction/power_cft.C b/src/instruction/power_cft.C index 612a3a86..9c611941 100644 --- a/src/instruction/power_cft.C +++ b/src/instruction/power_cft.C @@ -180,7 +180,9 @@ test_results_t power_cft_Mutator::executeTest() logerror("FAILED: instruction %s expected CFT, wasn't present", decodedInsns.front().format().c_str()); retVal = failure_accumulator(retVal, FAILED); } - cfts.pop_front(); + if(!cfts.empty()) { + cfts.pop_front(); + } } decodedInsns.pop_front();