Skip to content

Fix index out of bounds panic in FfmpegMetadata - #106

Merged
nathanbabcock merged 1 commit into
mainfrom
pullfrog/105-fix-metadata-index-panic
May 2, 2026
Merged

Fix index out of bounds panic in FfmpegMetadata#106
nathanbabcock merged 1 commit into
mainfrom
pullfrog/105-fix-metadata-index-panic

Conversation

@pullfrog

@pullfrog pullfrog Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #105

FfmpegMetadata::duration() panics with "index out of bounds: the len is 0 but the index is 0" when self.inputs is empty.

This replaces direct index access with safe alternatives:

  • duration() uses .first().and_then(...) instead of self.inputs[0].duration
  • handle_event for ParsedDuration uses .get_mut() instead of direct indexing

Both paths previously panicked when inputs were empty or the index was out of bounds.

Pullfrog  | View workflow run | via Pullfrog𝕏

Replace direct index access on `self.inputs` with safe alternatives:
- `duration()` now uses `.first()` instead of `[0]`
- `handle_event` for `ParsedDuration` now uses `.get_mut()` instead of
  direct indexing

Both previously panicked when `inputs` was empty or the index was out of
bounds.

Closes #105
@pullfrog
pullfrog Bot requested a review from nathanbabcock May 2, 2026 21:09
@nathanbabcock
nathanbabcock merged commit b0f48a5 into main May 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic: index out of bounds: the len is 0 but the index is 0

1 participant