mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-04-25 23:50:01 +00:00
[PR #1794] [MERGED] fix(dvb_subtitle_decoder): add NULL checks after malloc calls #2528
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/1794
Author: @cfsmp3
Created: 12/12/2025
Status: ✅ Merged
Merged: 12/12/2025
Merged by: @cfsmp3
Base:
master← Head:fix/dvb-subtitle-memory-safety📝 Commits (2)
877156cfix(matroska): add memory safety checks and fix memory leaksd02736bfix(dvb_subtitle_decoder): add NULL checks after malloc calls📊 Changes
2 files changed (+147 additions, -24 deletions)
View changed files
📝
src/lib_ccx/dvb_subtitle_decoder.c(+40 -3)📝
src/lib_ccx/matroska.c(+107 -21)📄 Description
Summary
This PR adds missing NULL checks for 9 malloc() calls in the DVB subtitle decoder (
src/lib_ccx/dvb_subtitle_decoder.c) that could cause crashes or undefined behavior if memory allocation fails.Changes
All checks use
fatal(EXIT_NOT_ENOUGH_MEMORY, ...)to terminate gracefully with an appropriate error message, consistent with the approach used inmatroska.cand other parts of the codebase.Affected Functions and Allocations
dvbsub_init_decoder()DVBSubContextdvbsub_parse_clut_segment()DVBSubCLUTdvbsub_parse_region_segment()DVBSubRegiondvbsub_parse_region_segment()region->pbufdvbsub_parse_region_segment()DVBSubObjectdvbsub_parse_region_segment()DVBSubObjectDisplaydvbsub_parse_page_segment()DVBSubRegionDisplaywrite_dvb_sub()cc_bitmap(rect)write_dvb_sub()rect->data1write_dvb_sub()rect->data0dvbsub_handle_display_segment()private_dataAdditional Fix
This also fixes a potential memory leak in
write_dvb_sub()whererectandrect->data1would be leaked if therect->data0allocation failed (previously returned -1 without cleanup, now terminates viafatal()).Context
This is part of a systematic effort to improve memory safety across the CCExtractor codebase. The DVB subtitle decoder was identified as having 28 memory-related function calls, making it a high-priority target for review.
Test plan
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.