pstats: Backport fix for crash when receiving frames out of order

This commit is contained in:
rdb 2025-02-25 17:32:44 +01:00
parent e270a073f4
commit 9a2203b9bb
1 changed files with 8 additions and 0 deletions

View File

@ -290,6 +290,14 @@ record_new_frame(int frame_number, PStatFrameData *frame_data) {
}
int index = frame_number - _first_frame_number;
// It's possible to receive frames out of order.
while (index < 0) {
_frames.push_front(nullptr);
++index;
--_first_frame_number;
}
nassertv(index >= 0 && index < (int)_frames.size());
if (_frames[index] != nullptr) {