Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix panic on len = 0 offsets #213

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions src/parser/src/first_pass/frameparser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,17 @@ impl FrameParser {
offsets.sort_by_key(|x| x.end);

let is_ok = check_all_bytes_are_covered(offsets, demo_bytes.len(), sender.clone());
sender
.send({
StartEndOffset {
start: 0,
end: 0,
msg_type: if is_ok {
StartEndType::EndOfMessages
} else {
StartEndType::MultithreadingWasNotOk
},
}
})
.unwrap();
let _ = sender.send({
StartEndOffset {
start: 0,
end: 0,
msg_type: if is_ok {
StartEndType::EndOfMessages
} else {
StartEndType::MultithreadingWasNotOk
},
}
});

Ok(())
}
Expand Down Expand Up @@ -205,7 +203,6 @@ impl FrameParser {
}
// If we are past our designated end and we find a fullpacket we exit
if ptr > end && frame.demo_cmd == csgoproto::demo::EDemoCommands::DEM_FullPacket {
// println!("EXIT {:?}", bef.elapsed());
return Ok(outs);
}
} else {
Expand All @@ -219,8 +216,8 @@ fn check_all_bytes_are_covered(mut sorted_offsets: Vec<StartEndOffset>, demo_len
sorted_offsets.dedup();
let mut send_ok = true;
// Check that no gaps in the ranges
for i in 0..sorted_offsets.len() - 1 {
if sorted_offsets[i].end != sorted_offsets[i + 1].start {
for w in sorted_offsets.windows(2) {
if w[0].end != w[1].start {
return false;
}
}
Expand Down
Loading