mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-04-20 21:20:28 +00:00
[PR #1792] [MERGED] fix(matroska): add memory safety checks and fix memory leaks #2524
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/1792
Author: @cfsmp3
Created: 12/12/2025
Status: ✅ Merged
Merged: 12/12/2025
Merged by: @cfsmp3
Base:
master← Head:fix/matroska-memory-safety📝 Commits (1)
877156cfix(matroska): add memory safety checks and fix memory leaks📊 Changes
1 file changed (+107 additions, -21 deletions)
View changed files
📝
src/lib_ccx/matroska.c(+107 -21)📄 Description
Summary
This PR addresses multiple memory safety issues in the Matroska parser (
src/lib_ccx/matroska.c) identified through static analysis using cppcheck.Issues Fixed
Details
Null pointer dereference after malloc (15 fixes)
malloc/calloccallsEXIT_NOT_ENOUGH_MEMORY(exit code 500) for OOM conditionsBuffer overflow fixes (3 fixes)
generate_timestamp_ass_ssa(): Buffer 15→32 bytes, sprintf→snprintfsave_sub_track(): number[] buffer 9→16 bytes, sprintf→snprintfgenerate_filename_from_track(): Dynamic buffer size calculationMemory leak fixes (7 fixes)
read_vint_block_string()return values inparse_ebml()andparse_segment_info()parse_segment_track_entry()wherelangwas reassigned without freeingsave_sub_track()where text pointer was advanced, losing original allocationRealloc error handling (3 fixes)
Use-after-free fix (1 fix)
matroska_loop(): Saved values beforematroska_free_all(), then used saved valuesMissing free fixes (2 fixes)
free(track->sentences)infree_sub_track()free(mkv_ctx->sub_tracks)inmatroska_free_all()Test plan
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.