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

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

Original Pull Request: https://github.com/CCExtractor/ccextractor/pull/2024

State: closed
Merged: No


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
**Original Pull Request:** https://github.com/CCExtractor/ccextractor/pull/2024 **State:** closed **Merged:** No --- <!-- 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
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#2829