Skip to content

Commit 3763140

Browse files
committed
Check unchecked iterator access
1 parent 6295079 commit 3763140

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/daemon/daemon.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3562,9 +3562,17 @@ mp::Daemon::async_wait_for_ssh_and_start_mounts_for(const std::string& name, con
35623562
try
35633563
{
35643564
auto it = operative_instances.find(name);
3565+
if (it == operative_instances.end())
3566+
{
3567+
// Level error since this can only occur because of a race condition or programming error.
3568+
auto msg = fmt::format("Instance '{}' cannot be waited on since it does not exist.\n", name);
3569+
mpl::log(mpl::Level::error, category, msg);
3570+
fmt::format_to(std::back_inserter(errors), msg);
3571+
return fmt::to_string(errors);
3572+
}
3573+
35653574
auto vm = it->second;
35663575

3567-
// unchecked iterator access :)
35683576
if (vm->current_state() == VirtualMachine::State::unavailable)
35693577
{
35703578
return fmt::to_string(errors);

0 commit comments

Comments
 (0)