From 42068b0df055455cf1b3c04a856fb004ca12eafe Mon Sep 17 00:00:00 2001 From: livepeer-tessa Date: Fri, 6 Mar 2026 08:35:38 +0000 Subject: [PATCH] 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 --- ffmpeg/encoder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ffmpeg/encoder.c b/ffmpeg/encoder.c index 3d049e0cf5..0cbca39209 100755 --- a/ffmpeg/encoder.c +++ b/ffmpeg/encoder.c @@ -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;