[PR #1878] [MERGED] [FIX] Handle NULL bitmap gracefully in OCR instead of crashing (#1010) #2658

Open
opened 2026-01-29 17:23:17 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/1878
Author: @cfsmp3
Created: 12/21/2025
Status: Merged
Merged: 12/22/2025
Merged by: @cfsmp3

Base: masterHead: fix/issue-1010-ocr-null-bitmap-crash


📝 Commits (1)

  • 3304c1b fix(ocr): Handle NULL bitmap gracefully instead of crashing (#1010)

📊 Changes

1 file changed (+41 additions, -17 deletions)

View changed files

📝 src/lib_ccx/ocr.c (+41 -17)

📄 Description

Summary

  • When processing DVB subtitles from live streams or corrupted files, bitmap clipping can fail
  • Previously this caused a fatal crash: "Failed to perform OCR - Failed to get text"
  • Now gracefully skips problematic frames instead of crashing

Root Cause

The code path was:

  1. pixClipRectangle fails → "box outside rectangle" error
  2. pixConvertRGBToGray receives NULL → "pixs not defined" error
  3. cpix_gs is NULL, but code continues to line 415
  4. TessBaseAPIGetUTF8Text returns NULL (no image was set)
  5. fatal() is called → crash

Fix

  • Handle cpix_gs == NULL by cleaning up and returning NULL (skip bitmap)
  • Change TessBaseAPIGetUTF8Text NULL case from fatal error to graceful skip
  • Both cases properly clean up allocated resources before returning

Testing

This fix allows CCExtractor to continue processing even when individual subtitle frames are corrupted, which is critical for live streams where packet loss can occur.

Fixes #1010

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/CCExtractor/ccextractor/pull/1878 **Author:** [@cfsmp3](https://github.com/cfsmp3) **Created:** 12/21/2025 **Status:** ✅ Merged **Merged:** 12/22/2025 **Merged by:** [@cfsmp3](https://github.com/cfsmp3) **Base:** `master` ← **Head:** `fix/issue-1010-ocr-null-bitmap-crash` --- ### 📝 Commits (1) - [`3304c1b`](https://github.com/CCExtractor/ccextractor/commit/3304c1b094604c38ef21bb0d3b7823ef469400c2) fix(ocr): Handle NULL bitmap gracefully instead of crashing (#1010) ### 📊 Changes **1 file changed** (+41 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `src/lib_ccx/ocr.c` (+41 -17) </details> ### 📄 Description ## Summary - When processing DVB subtitles from live streams or corrupted files, bitmap clipping can fail - Previously this caused a fatal crash: "Failed to perform OCR - Failed to get text" - Now gracefully skips problematic frames instead of crashing ## Root Cause The code path was: 1. `pixClipRectangle` fails → "box outside rectangle" error 2. `pixConvertRGBToGray` receives NULL → "pixs not defined" error 3. `cpix_gs` is NULL, but code continues to line 415 4. `TessBaseAPIGetUTF8Text` returns NULL (no image was set) 5. `fatal()` is called → crash ## Fix - Handle `cpix_gs == NULL` by cleaning up and returning NULL (skip bitmap) - Change `TessBaseAPIGetUTF8Text` NULL case from fatal error to graceful skip - Both cases properly clean up allocated resources before returning ## Testing This fix allows CCExtractor to continue processing even when individual subtitle frames are corrupted, which is critical for live streams where packet loss can occur. Fixes #1010 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 17:23:17 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2658