mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-07-08 18:06:30 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user