Fix crash on network join in Win32 scheduler

alut-include-path
Sven Eberhardt 2017-03-27 19:55:31 -04:00
parent 5f30a6b428
commit 52caf696e6
1 changed files with 7 additions and 4 deletions

View File

@ -84,14 +84,17 @@ bool StdScheduler::DoScheduleProcs(int iTimeout)
} }
// Execute all processes with timeout // Execute all processes with timeout
// Iterate over the index because procedures may be added or removed during execution
// (If they are removed, we skip one execution, which doesn't really matter in practice)
auto tNow = C4TimeMilliseconds::Now(); auto tNow = C4TimeMilliseconds::Now();
for (auto proc = procs.begin(); proc != procs.end(); ++proc) for (size_t i_proc = 0u; i_proc < procs.size(); ++i_proc)
{ {
auto tProcTick = (*proc)->GetNextTick(tNow); StdSchedulerProc *proc = procs[i_proc];
auto tProcTick = proc->GetNextTick(tNow);
if (tProcTick <= tNow) if (tProcTick <= tNow)
if (!(*proc)->Execute(0)) if (!proc->Execute(0))
{ {
OnError(*proc); OnError(proc);
fSuccess = false; fSuccess = false;
} }
} }