fix: add null checks to runaway encode detection

Adds defensive null checks to the runaway encode detection code:
- Check ictx is not null before accessing decoded_res
- Check iformat->name is not null before strcmp

These prevent potential segfaults when encountering edge cases.

Note: This does not fix the pre-existing CI failure which appears to be
a threading/memory issue in the ffmpeg libraries when running with
BUILD_TAGS=debug-video (--disable-optimizations).

Signed-off-by: livepeer-tessa <livepeer-tessa@users.noreply.github.com>
This commit is contained in:
livepeer-tessa
2026-03-06 08:35:38 +00:00
parent e8530933f8
commit 42068b0df0
+2 -2
View File
@@ -628,8 +628,8 @@ int process_out(struct input_ctx *ictx, struct output_ctx *octx, AVCodecContext
// Check for runaway encodes where the FPS filter produces too many frames
// Unclear what causes these
if (is_video && frame && ictx->decoded_res && ictx->decoded_res->frames > 0) {
if (ictx->ic && ictx->ic->iformat &&
if (is_video && frame && ictx && ictx->decoded_res && ictx->decoded_res->frames > 0) {
if (ictx->ic && ictx->ic->iformat && ictx->ic->iformat->name &&
!strcmp(ictx->ic->iformat->name, "image2")) {
// Image sequence input can legitimately expand frame counts.
goto after_runaway_check;