mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-04-18 12:03:00 +00:00
[PR #1839] [MERGED] fix(rust-ffi): Prevent dangling pointers in copy_from_rust #2596
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/1839
Author: @cfsmp3
Created: 12/17/2025
Status: ✅ Merged
Merged: 12/17/2025
Merged by: @cfsmp3
Base:
master← Head:fix/rust-ffi-dangling-pointers📝 Commits (1)
ba33f75fix(rust-ffi): Prevent dangling pointers in copy_from_rust📊 Changes
2 files changed (+11 additions, -0 deletions)
View changed files
📝
src/lib_ccx/ccx_common_option.c(+1 -0)📝
src/rust/src/common.rs(+10 -0)📄 Description
Summary
copy_from_rust()function that caused memory corruptionsettings_dtvcc.timing = NULLinitialization in C'sinit_options()Problem
The
to_ctype()implementations forDecoderDtvccSettingsandDecoder608Settingswere creating temporaries on the stack and returning pointers to them:When
copy_from_rust()calledto_ctype(), these dangling pointers were written to the Cccx_optionsstruct. Later when C code tried to usesettings_dtvcc.reportorsettings_dtvcc.timing, it accessed invalid memory.Valgrind errors before this fix:
Solution
Preserve the original C-managed pointers instead of overwriting them with dangling pointers:
Test plan
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.