mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-07-08 18:06:30 +00:00
[PR #1797] [CLOSED] fix(ccx_encoders_spupng): add NULL checks and fix memory leaks #2534
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/1797
Author: @cfsmp3
Created: 12/12/2025
Status: ❌ Closed
Base:
master← Head:fix/ccx-encoders-spupng-memory-safety📄 Description
Summary
This PR addresses 7 memory safety issues in
ccx_encoders_spupng.c, identified as part of the systematic bug analysis effort (see Phase 2.1 in the bug analysis plan).NULL Pointer Dereference Fixes (Crash Prevention)
write_cc_bitmap_as_spupng()pbufnot checked after malloc, then used in memsetfatal()on NULLwrite_image()rownot checked after malloc, then used in loopgoto finalisecleanupcenter_justify()temp_buffernot checked after mallocfatal()on NULLutf8_to_utf32()string_utf32not checked after callocfatal()on NULLspupng_export_string2png()memset(NULL, ...)fatal()Memory Leak Fixes
spupng_export_string2png()bufferleaked whenstrdup(str)failedfree(buffer)before returnspupng_export_string2png()buffer,tmp, andstring_utf32leaked on realloc failurefatal()Error Handling Pattern
All
fatal()calls include diagnostic information to aid debugging:Example:
Context
This file was identified as a HIGH priority target in the bug analysis plan due to having 49 malloc/free occurrences. The SPUPNG encoder handles PNG subtitle generation and processes untrusted input data, making memory safety critical.
Test plan
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.