make the buffer slicing checked instead of assumed

This commit is contained in:
2026-09-21 01:27:56 +03:00
parent e6e0d5b2b4
commit 9e23a5b7d3
6 changed files with 40 additions and 15 deletions
+5 -3
View File
@@ -152,7 +152,9 @@ fn click_filters(clicks: &[Click], clip_w: u32, clip_h: u32) -> Option<String> {
MAX_CLICK_HIGHLIGHTS
);
}
for click in &clicks[..clicks_to_render] {
// clicks_to_render is clicks.len().min(MAX_CLICK_HIGHLIGHTS), and get()
// falls back to the whole slice rather than panicking.
for click in clicks.get(..clicks_to_render).unwrap_or(clicks) {
// Clicks recorded outside the capture region (or outside the crop) land
// behind the origin. Clamping here keeps the box inside the frame;
// without it the offsets went negative and drawbox dropped the box.
@@ -1098,8 +1100,8 @@ pub(crate) fn concat_segments(ffmpeg: &Path, segments: &[PathBuf], output: &Path
if segments.is_empty() {
bail!("no segments to concatenate");
}
if segments.len() == 1 {
std::fs::copy(&segments[0], output).context("copying single segment")?;
if let [only] = segments {
std::fs::copy(only, output).context("copying single segment")?;
return Ok(());
}