Open
Conversation
Added error handling for memory allocation and codec initialization in hardsubx_process_data function.
Added comment to clarify the purpose of the hardsubx function.
This was referenced Mar 1, 2026
Collaborator
CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit f377be9...:
Congratulations: Merging this PR would fix the following tests:
All tests passed completely. Check the result page for more info. |
Collaborator
CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit f377be9...:
Your PR breaks these cases:
It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you). Check the result page for more info. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[FIX] Fix resource leaks, missing NULL checks, and missing return in hardsubx.c
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
What does this PR do?
Fixes several error-handling issues in
src/lib_ccx/hardsubx.cacross both_init_hardsubx()andhardsubx_process_data().Changes in
_init_hardsubx()Added NULL check for
TessBaseAPICreate(): The return value was never validated. If it returned NULL, every subsequent Tesseract call would hit undefined behavior.Added NULL checks for both
strdup()calls:pars_vecandpars_valueswere used without checking ifstrdup()succeeded. On memory allocation failure these would be NULL pointers passed intoTessBaseAPIInit4().Added
TessBaseAPIDelete()in error paths: Whentessdata_pathlookup failed orTessBaseAPIInit4()returned non-zero, the code calledfree(ctx)without first deleting the Tesseract handle that was already created. This leaked the handle every time one of these error paths was hit.Changes in
hardsubx_process_data()Added missing return statement: The function is declared as returning
intbut never actually returned a value, which is undefined behavior per the C standard.Added NULL checks for
av_malloc(),sws_getContext(), andinit_encoder(): All three can return NULL on failure, but the results were being used directly without any validation.Replaced per-error cleanup with
goto cleanuppattern: Previously, eachfatal()call would exit without freeing any of the FFmpeg resources allocated up to that point (codec context, format context, frames, buffers, etc.). Now all error paths jump to a centralized cleanup section that safely frees everything that was allocated.Issues Fixed
Fixes #2158
Fixes #2160
Fixes #2161
Testing
free(NULL)is a no-op per the C standard,av_frame_free()andavcodec_free_context()handle NULL pointers )