-
Notifications
You must be signed in to change notification settings - Fork 561
Description
There are several issues in hardsubx_process_data() in src/lib_ccx/hardsubx.c:
-
No return statement. The function is declared as
intbut never returns anything. This will lead to undefined behavior if the caller ever tries to use the return value. -
av_malloc()result is not checked . If allocation fails, the NULL pointer gets passed intoav_image_fill_arrays()and later into frame processing. This might cause segfault. -
sws_getContext()result is not checked. The code checks for NULL before callingsws_freeContext()at the end, but never checks after creation. The code doesn't guard against it even after possibility of NULL -
init_encoder()result is not checked. The pointer goes into the processing functions anddinit_encoder()without any validation. -
Resource leaks in error paths. Every
fatal()call in the function just exits without cleaning up whatever was allocated before that point. For example, ifavcodec_open2()fails,codec_ctxandformat_ctxare leaked. Ifav_frame_alloc()fails, add frames to that list, etc.
Suggested fix:
- Use of a
goto cleanuppattern with a centralized cleanup section at the end of the function. This avoids repeating cleanup code in every error path and makes it easy to add new allocations later without forgetting to clean them up. - add the missing NULL checks and a proper return value.