mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-04 05:44:53 +00:00
fix(avc): prevent segfault in report-only mode (-out=report)
When using -out=report mode, the encoder context (enc_ctx) is NULL because no output file needs to be created. The Rust FFI function ccxr_process_avc was dereferencing this NULL pointer, causing a segmentation fault. Add NULL pointer checks at the FFI boundary to skip AVC processing when enc_ctx is NULL. This is safe because report mode only needs stream analysis, not caption extraction. Fixes #2023 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,19 @@ pub unsafe extern "C" fn ccxr_process_avc(
|
||||
return 0;
|
||||
}
|
||||
|
||||
// In report-only mode (-out=report), enc_ctx is NULL because no encoder is created.
|
||||
// Skip AVC processing in this case since we can't output captions without an encoder.
|
||||
// Return the full buffer length to indicate we've "consumed" the data.
|
||||
if enc_ctx.is_null() {
|
||||
return avcbuflen;
|
||||
}
|
||||
|
||||
// dec_ctx and sub should never be NULL in normal operation, but check defensively
|
||||
if dec_ctx.is_null() || sub.is_null() {
|
||||
info!("Warning: dec_ctx or sub is NULL in ccxr_process_avc");
|
||||
return avcbuflen;
|
||||
}
|
||||
|
||||
// Create a safe slice from the raw pointer
|
||||
let avc_slice = std::slice::from_raw_parts_mut(avcbuf, avcbuflen);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user