VobSub parser crashes when an idx offset does not point at a pack header

Open
#69 0 comments 0 reactions 0 assignees View on GitHub

@ecdye is already working on this.

Since Nov 27, 2026.

  • #102 by @ecdye — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
swift
Domain
backend

Research direction

Read Sources/macSubtitleOCR/Subtitles/VobSub/VobSubParser.swift, starting at VobSubParser.readSubFrame and tracing the packet loop for missing pack headers and PTS flags. Check how subtitle parsing reports per-subtitle errors or empty subtitles, then confirm both malformed first-packet cases no longer trap.

Written by the indexing model from the issue text.

Description

bug

VobSubParser.readSubFrame (Sources/macSubtitleOCR/Subtitles/VobSub/VobSubParser.swift) prints "No VobSub PS packet at offset …, trying to decode anyway" and breaks out of the packet loop, but controlSize is still nil, so the controlSize! in the loop condition / the check after it traps.

The same happens when the first packet has no PTS flag (e.g. the idx filepos points at a continuation packet): firstPacketFound stays false and controlOffset! traps.

Fix: treat a subpicture whose first packet cannot be read as invalid (throw a per-subtitle error / return an empty subtitle) instead of force unwrapping.

Dominant language
Swift
Stars
42
Forks
9
Avg merge
9h 30m
Merged PRs (30d)
4

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ecdye/macSubtitleOCR

All issues in ecdye/macSubtitleOCR

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.