Skip to content

[BUG] Rust panic in teletext subtitle output on negative or malformed PTS timestamps #2233

@NexionisJake

Description

@NexionisJake

Summary

TeletextContext::process_page() calls .to_srt_time().expect(...) on both
show_timestamp and hide_timestamp. For teletext streams with uninitialized,
wrap-around, or malformed PTS values, Timestamp can hold a negative value.
to_srt_time()as_hms_millis() calls i64::try_into::<u64>() which
returns TimestampError::OutOfRangeError for negative values — and .expect()
converts this into an unconditional panic crash.

Location

src/rust/lib_ccxr/src/teletext.rs

  • Line ~1010: show_timestamp.to_srt_time().expect("could not format to SRT time")
  • Line ~1015: hide_timestamp.to_srt_time().expect("could not format to SRT time")

Code

let start = show_timestamp.to_srt_time().expect("could not format to SRT time");
let end   = hide_timestamp.to_srt_time().expect("could not format to SRT time");

Impact

Any teletext stream with an uninitialized or wrap-around PTS (common in
broadcast captures and partial recordings) crashes CCExtractor unconditionally
at subtitle output time, potentially after processing an entire file successfully.

Suggested Fix

Either propagate the error gracefully:

let start = show_timestamp.to_srt_time().ok()?;  // returns None from process_page()
let end   = hide_timestamp.to_srt_time().ok()?;

Or clamp negative timestamps to zero before formatting:

let safe_show = show_timestamp.max(Timestamp::from_millis(0));
let safe_hide = hide_timestamp.max(Timestamp::from_millis(0));

Environment

  • Affects all platforms
  • Triggered by teletext streams with negative or malformed PTS values

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions