Fix panic in process_page() on negative teletext PTS timestamps (#2240)

show_timestamp.to_srt_time().expect() and hide_timestamp.to_srt_time().expect()
in TeletextContext::process_page() panicked for any negative Timestamp value.
Negative timestamps are common in broadcast captures with wrap-around or
uninitialized PTS — crashing after potentially processing an entire file.

to_srt_time() → as_hms_millis() → i64::try_into::<u64>() returns
OutOfRangeError for negative values; .expect() made this fatal.

Fix: process_page() already returns Option<Subtitle>, so replace both
.expect() calls with .ok()? — silently skipping the subtitle when the
timestamp is out of range, matching the function's existing None-on-empty
contract.

Fixes #2233
This commit is contained in:
Abhijeet Kumar
2026-04-04 08:20:14 +05:30
committed by GitHub
parent d56a6be9e4
commit 92dc785435

View File

@@ -1003,16 +1003,17 @@ impl<'a> TeletextContext<'a> {
let mut line_count: u8 = 0;
let mut time_reported = false;
// Negative timestamps occur with wrap-around/uninitialized PTS in broadcast captures
let timecode_show = self
.page_buffer
.show_timestamp
.to_srt_time()
.expect("could not format to SRT time");
.ok()?;
let timecode_hide = self
.page_buffer
.hide_timestamp
.to_srt_time()
.expect("could not format to SRT time");
.ok()?;
// process data
for row in 1..25 {