mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-04-24 15:09:55 +00:00
[PR #1840] fix(memory): Fix uninitialized memory and memory leaks found by Valgrind #2603
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?
Original Pull Request: https://github.com/CCExtractor/ccextractor/pull/1840
State: closed
Merged: Yes
Summary
Comprehensive memory fixes found via Valgrind testing. This PR eliminates memory leaks, use-after-free bugs, and uninitialized memory issues across both C and Rust code.
Commits
calloc()instead ofmalloc()in demuxer/decoder initcopy_from_rust()is called multiple timesdec_ctx->private_dataafter Teletext context is freeddinit_cc_decode()xds_strwhen skipping invalid timestamps--in=binand--in=rawformatsValgrind Test Results (245 tests)
All tested ranges show 0 bytes definitely lost.
Key Fixes Verified
Technical Details
C Code Fixes
ccx_demuxer.c:calloc()ininit_demuxer()lib_ccx.c:calloc()ininit_decoder_setting()telxcc.c:calloc()intelxcc_init()general_loop.c: Initialize variables, add rcwt_loop cleanupccx_decoders_common.c: Free DVB bitmap and XDS strings in cleanupccx_encoders_common.c: Free XDS strings on invalid timestamp skipRust FFI Fixes
utils.rs: Addreplace_rust_c_string(),free_rust_c_string_array()common.rs: Only set inputfile/enc_cfg on first call to prevent leaksdemuxer.rs: Direct C struct manipulation inccxr_demuxer_close()decoder/mod.rs: Only allocate encoder whenctx.encoderis nullcommon_types.rs: AddDropforCcxDemuxerto free FFI allocationsKnown Pre-existing Issues
--datapid(complex interaction, pre-existing)Test plan
🤖 Generated with Claude Code