mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-03 21:23:48 +00:00
[PR #1999] [MERGED] fix prevent FFI memory leaks in demuxer sync #2801
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/CCExtractor/ccextractor/pull/1999
Author: @THE-Amrit-mahto-05
Created: 1/8/2026
Status: ✅ Merged
Merged: 1/9/2026
Merged by: @cfsmp3
Base:
master← Head:fix/demuxer-ffi-memory-leak📝 Commits (1)
1911068fix(rust): prevent FFI memory leaks in demuxer sync📊 Changes
2 files changed (+59 additions, -43 deletions)
View changed files
📝
src/rust/src/demuxer/common_types.rs(+3 -1)📝
src/rust/src/libccxr_exports/demuxer.rs(+56 -42)📄 Description
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Summary
fixes multiple memory leaks and unsafe pointer overwrites in the Rust–C FFI demuxer synchronization logic.
The issues occur when Rust demuxer state is copied into C structures repeatedly (e.g. during resets), causing existing C-owned pointers to be overwritten without being freed.
Problem
In
copy_demuxer_from_rust_to_c, existing pointers inPID_buffersandPIDs_programswere overwritten without freeing the previous allocations, leading to cumulative memory leaks during demuxing.PSIBuffer::default()initializedbufferwith a dummy heap allocation instead ofNULL, which:Both issues become more visible when the demuxer is reset or reused multiple times.
Fixes
demuxer.rs
Box::from_rawto avoid undefined behaviorcommon_types.rs
PSIBuffer::bufferwithstd::ptr::null_mut()instead of a 1-byte allocationImpact
Verification
cargo testpasses insrc/rust🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.