mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-04-20 21:20:28 +00:00
[PR #1839] fix(rust-ffi): Prevent dangling pointers in copy_from_rust #2601
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/1839
State: closed
Merged: Yes
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