Skip to content

Commit

Permalink
Fix an error where time travelling with no chrono tasks would cause a…
Browse files Browse the repository at this point in the history
… segmentation fault
  • Loading branch information
TrentHouliston committed Apr 30, 2024
1 parent 907b50e commit 8906fa3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/extension/ChronoController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,10 @@ namespace extension {

} break;
case message::TimeTravel::Action::NEAREST: {
auto next_task =
std::min_element(tasks.begin(), tasks.end(), [](const ChronoTask& a, const ChronoTask& b) {
return a.time < b.time;
});
clock::set_clock(std::min(next_task->time, travel.target), travel.rtf);
clock::time_point nearest =
tasks.empty() ? travel.target
: std::min(travel.target, std::min_element(tasks.begin(), tasks.end())->time);
clock::set_clock(nearest, travel.rtf);
} break;
}

Expand Down

0 comments on commit 8906fa3

Please sign in to comment.