CTest: Ignore a checkpoint entry for a test that is not pending

CheckResume() reads the checkpoint `ctest -F` resumes from and removes each
test it names.  RemoveTest() erased the iterator std::find returned without
checking it, so a checkpoint naming a test the current run does not have
pending -- one written before the test list changed, say -- erased the end
iterator of a std::list, which is undefined behavior.  Skip such an entry
instead.
This commit is contained in:
Taylor Braun-Jones
2026-09-18 08:28:42 -04:00
committed by Brad King
parent 32b25b94d6
commit 4fcf3dd296
+7 -2
View File
@@ -1638,8 +1638,13 @@ void cmCTestMultiProcessHandler::CheckResume()
void cmCTestMultiProcessHandler::RemoveTest(int index)
{
this->OrderedTests.erase(
std::find(this->OrderedTests.begin(), this->OrderedTests.end(), index));
auto const oi =
std::find(this->OrderedTests.begin(), this->OrderedTests.end(), index);
if (oi == this->OrderedTests.end()) {
// The checkpoint names a test this run does not have pending.
return;
}
this->OrderedTests.erase(oi);
this->PendingTests.erase(index);
this->Properties.erase(index);
this->Completed++;