Skip to content

Commit 92dc785

Browse files
authored
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
1 parent d56a6be commit 92dc785

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/rust/lib_ccxr/src/teletext.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,16 +1003,17 @@ impl<'a> TeletextContext<'a> {
10031003

10041004
let mut line_count: u8 = 0;
10051005
let mut time_reported = false;
1006+
// Negative timestamps occur with wrap-around/uninitialized PTS in broadcast captures
10061007
let timecode_show = self
10071008
.page_buffer
10081009
.show_timestamp
10091010
.to_srt_time()
1010-
.expect("could not format to SRT time");
1011+
.ok()?;
10111012
let timecode_hide = self
10121013
.page_buffer
10131014
.hide_timestamp
10141015
.to_srt_time()
1015-
.expect("could not format to SRT time");
1016+
.ok()?;
10161017

10171018
// process data
10181019
for row in 1..25 {

0 commit comments

Comments
 (0)