mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-07-08 18:06:30 +00:00
[PR #1847] [MERGED] fix(hardsubx): Fix heap corruption from Rust/C allocator mismatch #2609
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/1847
Author: @cfsmp3
Created: 12/19/2025
Status: ✅ Merged
Merged: 12/19/2025
Merged by: @cfsmp3
Base:
master← Head:ci/triage-failing-tests-dec-2025📝 Commits (7)
2fa023bci: Add triage tracking file for December 2025 CI analysis0ef7227ci: Add dummy C file to trigger Sample Platform CI0e815c6fix(hardsubx): Fix crash in _dinit_hardsubx due to incorrect freep usage6399936fix(hardsubx): Fix multiple memory bugs causing crashes80a117efix(hardsubx): Fix memory leaks in hardsubx processing80957d6fix(hardsubx): Fix heap corruption from Rust/C allocator mismatch0b74c92fix(rcwt): Fix incorrect exit code when captions are found in BIN format📊 Changes
8 files changed (+106 additions, -38 deletions)
View changed files
➕
CI_TRIAGE_DEC_2025.md(+22 -0)📝
src/lib_ccx/general_loop.c(+11 -0)📝
src/lib_ccx/hardsubx.c(+7 -2)📝
src/lib_ccx/hardsubx.h(+4 -0)📝
src/lib_ccx/hardsubx_decoder.c(+18 -0)📝
src/rust/src/hardsubx/classifier.rs(+27 -18)📝
src/rust/src/hardsubx/decoder.rs(+15 -17)📝
src/rust/src/utils.rs(+2 -1)📄 Description
Summary
Fixes heap corruption in hardsubx (burned-in subtitle extraction) that caused garbage OCR output after processing ~27 subtitle frames.
Root Cause
The C code was using
free()on strings allocated by Rust'sCString::into_raw(). Since Rust and C use different memory allocators, this caused heap corruption that accumulated over time, eventually corrupting the OCR results.Changes
free_rust_c_string()asextern "C"functionfree_rust_c_string()for C codefree(subtitle_text)withfree_rust_c_string(subtitle_text)for Rust-allocated stringsprocess_hardsubx_linear_frames_and_normal_subs()wheresubtitle_text_hardandprev_subtitle_text_hardwere not freedTesting
Before/After
Before (memory corruption):
After (correct output):
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.