Skip to content

Commit

Permalink
fix panic on len = 0 offsets (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaihoE authored Aug 24, 2024
1 parent 9658bd5 commit 0c1e37a
Showing 1 changed file with 13 additions and 16 deletions.
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

0 comments on commit 0c1e37a

Please sign in to comment.