[PR #2024] [CLOSED] Fix: Prevent AVC segfault in report-only mode (-out=report) #2826

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

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/2024
Author: @x15sr71
Created: 1/16/2026
Status: Closed

Base: masterHead: fix/report-mode-avc-segfault


📝 Commits (2)

  • 6b393a9 fix: prevent AVC segfault in report-only(-out=report) mode
  • 11df2af docs(changelog): mention fix for AVC segfault in report-only mode

📊 Changes

2 files changed (+7 additions, -0 deletions)

View changed files

📝 docs/CHANGES.TXT (+1 -0)
📝 src/lib_ccx/avc_functions.c (+6 -0)

📄 Description

In raising this pull request, I confirm the following (please check boxes):

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.
  • I have mentioned this change in the changelog.

My familiarity with the project is as follows (check one):

  • I have never used CCExtractor.
  • I have used CCExtractor just a couple of times.
  • I absolutely love CCExtractor, but have not contributed previously.
  • I am an active contributor to CCExtractor.

Summary

This PR fixes a segmentation fault that occurs (as reported in issue #2023) when running CCExtractor in report-only mode (-out=report) on files containing AVC (H.264) video streams with the Rust AVC decoder enabled.


Problem

When running:

./ccextractor -out=report input.ts

on transport streams containing AVC/H.264 video, CCExtractor crashes with a segmentation fault.

Solution

Add a defensive guard at the C → Rust FFI boundary in process_avc() to skip AVC processing when the decoder context isn't fully initialized (such as in report-only mode).

Guard Conditions

Skip calling the Rust AVC decoder if any of the following are true:

  • encoder_ctx is NULL
  • encoder_ctx->timing is NULL
  • lib_cc_decode is NULL
  • lib_cc_decode->avc_ctx is NULL

In these cases, process_avc() simply returns without invoking the Rust decoder.

Rationale

  • The fix belongs at the C → Rust boundary, where assumptions about initialization must be enforced
  • Only affects process_avc(); no changes to Rust internals
  • Report-only mode does not require AVC frame decoding.
  • Prevents similar crashes if decoding state isn't initialized elsewhere

🔄 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/2024 **Author:** [@x15sr71](https://github.com/x15sr71) **Created:** 1/16/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `fix/report-mode-avc-segfault` --- ### 📝 Commits (2) - [`6b393a9`](https://github.com/CCExtractor/ccextractor/commit/6b393a9df64b1bde99703108a265182affafd825) fix: prevent AVC segfault in report-only(-out=report) mode - [`11df2af`](https://github.com/CCExtractor/ccextractor/commit/11df2af1354ba0e0860a837c6fbdb263654ec0d6) docs(changelog): mention fix for AVC segfault in report-only mode ### 📊 Changes **2 files changed** (+7 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/CHANGES.TXT` (+1 -0) 📝 `src/lib_ccx/avc_functions.c` (+6 -0) </details> ### 📄 Description <!-- Please prefix your pull request with one of the following: **[FEATURE]** **[FIX]** **[IMPROVEMENT]**. --> **In raising this pull request, I confirm the following (please check boxes):** - [X] I have read and understood the [contributors guide](https://github.com/CCExtractor/ccextractor/blob/master/.github/CONTRIBUTING.md). - [X] I have checked that another pull request for this purpose does not exist. - [X] I have considered, and confirmed that this submission will be valuable to others. - [X] I accept that this submission may not be used, and the pull request closed at the will of the maintainer. - [X] I give this submission freely, and claim no ownership to its content. - [X] **I have mentioned this change in the [changelog](https://github.com/CCExtractor/ccextractor/blob/master/docs/CHANGES.TXT).** **My familiarity with the project is as follows (check one):** - [ ] I have never used CCExtractor. - [ ] I have used CCExtractor just a couple of times. - [ ] I absolutely love CCExtractor, but have not contributed previously. - [X] I am an active contributor to CCExtractor. --- ### Summary This PR fixes a segmentation fault that occurs (as reported in issue #2023) when running CCExtractor in report-only mode (`-out=report`) on files containing AVC (H.264) video streams with the Rust AVC decoder enabled. --- ### Problem When running: ```bash ./ccextractor -out=report input.ts ``` on transport streams containing AVC/H.264 video, CCExtractor crashes with a segmentation fault. ### Solution Add a defensive guard at the C → Rust FFI boundary in `process_avc()` to skip AVC processing when the decoder context isn't fully initialized (such as in report-only mode). ### Guard Conditions Skip calling the Rust AVC decoder if any of the following are true: - `encoder_ctx` is NULL - `encoder_ctx->timing` is NULL - `lib_cc_decode` is NULL - `lib_cc_decode->avc_ctx` is NULL In these cases, `process_avc()` simply returns without invoking the Rust decoder. ## Rationale - The fix belongs at the C → Rust boundary, where assumptions about initialization must be enforced - Only affects `process_avc()`; no changes to Rust internals - Report-only mode does not require AVC frame decoding. - Prevents similar crashes if decoding state isn't initialized elsewhere --- <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:24:06 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2826