From 70f95fca6bf1d9a7db5dab49adcdd9eb26d6c03d Mon Sep 17 00:00:00 2001 From: NexionisJake Date: Sun, 29 Mar 2026 10:13:07 +0530 Subject: [PATCH] Fix panic in process_page() on negative teletext PTS timestamps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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::() returns OutOfRangeError for negative values; .expect() made this fatal. Fix: process_page() already returns Option, 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 --- src/rust/lib_ccxr/src/teletext.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rust/lib_ccxr/src/teletext.rs b/src/rust/lib_ccxr/src/teletext.rs index 4b3405d11..906183bc8 100644 --- a/src/rust/lib_ccxr/src/teletext.rs +++ b/src/rust/lib_ccxr/src/teletext.rs @@ -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 {