Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

security(mpegts): avoid repeated audio buffer drains (#2898)

Earl Cob9689dd3a36a
diff --git a/crates/mpegts/src/es.rs b/crates/mpegts/src/es.rs
index 9735d456e..3219b4d60 100644
--- a/crates/mpegts/src/es.rs
+++ b/crates/mpegts/src/es.rs
@@ -652,11 +652,14 @@ impl Splitter {
match next {
Some(d) => {
self.skipped += d as u64;
- self.trim(self.buf.len() - (i + 1 + d));
+ // Keep a cursor into the current window rather than draining its
+ // prefix for every false sync candidate.
+ self.next_frame = Some(at + 1 + d as u64);
}
None => {
self.skipped += (self.buf.len() - i - 1) as u64;
- self.trim(0);
+ // A split header can begin in the final few bytes; compact once.
+ self.trim(7);
return;
}
}