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

Ensure next_piece_idx is always in bounds of pieces #6

Merged
merged 2 commits into from
Dec 20, 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
4 changes: 2 additions & 2 deletions src/codec/h265.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ impl Depacketizer {
self.log_access_unit(&au, reason);
}
for nal in &self.nals {
let next_piece_idx = usize::try_from(nal.next_piece_idx).expect("u32 fits in usize");
let next_piece_idx = std::cmp::min(nal.next_piece_idx as usize, self.pieces.len());
let nal_pieces = &self.pieces[piece_idx..next_piece_idx];
match nal.hdr.nal_unit_type() {
UnitType::NalVps => {
Expand Down Expand Up @@ -522,7 +522,7 @@ impl Depacketizer {
let mut nals = vec![];
piece_idx = 0;
for nal in &self.nals {
let next_piece_idx = usize::try_from(nal.next_piece_idx).expect("u32 fits in usize");
let next_piece_idx = std::cmp::min(nal.next_piece_idx as usize, self.pieces.len());
let nal_pieces = &self.pieces[piece_idx..next_piece_idx];

nals.extend_from_slice(&[0, 0, 0, 1]);
Expand Down
Loading