1
0
Fork 0

src/Aircraft/replay.cxx: fixed potential segv when moving packest between medium/long term store.

This commit is contained in:
Julian Smith 2021-04-17 19:21:41 +01:00
parent 967cff2b6f
commit 3e57ba3332

View file

@ -1176,35 +1176,41 @@ FGReplay::update( double dt )
short_term.pop_front(); short_term.pop_front();
} }
FGReplayData *mt_front = medium_term.front(); if (!medium_term.empty())
if ( sim_time - mt_front->sim_time > m_medium_res_time )
{ {
while ( !medium_term.empty() && sim_time - mt_front->sim_time > m_medium_res_time ) FGReplayData *mt_front = medium_term.front();
if ( sim_time - mt_front->sim_time > m_medium_res_time )
{ {
mt_front = medium_term.front(); while ( !medium_term.empty() && sim_time - mt_front->sim_time > m_medium_res_time )
MoveFrontMultiplayerPackets(medium_term); {
recycler.push_back(mt_front);
medium_term.pop_front();
}
// update the long term list
if ( sim_time - last_lt_time > m_long_sample_rate )
{
last_lt_time = sim_time;
if (!medium_term.empty()) {
mt_front = medium_term.front(); mt_front = medium_term.front();
long_term.push_back( mt_front ); MoveFrontMultiplayerPackets(medium_term);
recycler.push_back(mt_front);
medium_term.pop_front(); medium_term.pop_front();
} }
// update the long term list
FGReplayData *lt_front = long_term.front(); if ( sim_time - last_lt_time > m_long_sample_rate )
if ( sim_time - lt_front->sim_time > m_low_res_time )
{ {
while ( !long_term.empty() && sim_time - lt_front->sim_time > m_low_res_time ) last_lt_time = sim_time;
if (!medium_term.empty()) {
mt_front = medium_term.front();
long_term.push_back( mt_front );
medium_term.pop_front();
}
if (!long_term.empty())
{ {
lt_front = long_term.front(); FGReplayData *lt_front = long_term.front();
MoveFrontMultiplayerPackets(long_term); if ( sim_time - lt_front->sim_time > m_low_res_time )
recycler.push_back(lt_front); {
long_term.pop_front(); while ( !long_term.empty() && sim_time - lt_front->sim_time > m_low_res_time )
{
lt_front = long_term.front();
MoveFrontMultiplayerPackets(long_term);
recycler.push_back(lt_front);
long_term.pop_front();
}
}
} }
} }
} }