From: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Sep 2025 11:51:32 +0000 (+0000) Subject: Fix root cause: validate codec parameters early in tvh_context_setup X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ef040d1818e3cc0aadc2da3e925d948be53bb606;p=thirdparty%2Ftvheadend.git Fix root cause: validate codec parameters early in tvh_context_setup Co-authored-by: Flole998 <9951871+Flole998@users.noreply.github.com> --- diff --git a/src/transcoding/transcode/context.c b/src/transcoding/transcode/context.c index 6d939e8f0..c2bc8a0e3 100644 --- a/src/transcoding/transcode/context.c +++ b/src/transcoding/transcode/context.c @@ -240,6 +240,12 @@ tvh_context_setup(TVHContext *self, const AVCodec *iavcodec, const AVCodec *oavc enum AVMediaType media_type = iavcodec->type; const char *media_type_name = av_get_media_type_string(media_type); + if (!iavcodec || !oavcodec) { + tvh_stream_log(self->stream, LOG_ERR, + "invalid codec parameters: input=%p output=%p", + iavcodec, oavcodec); + return -1; + } if (!(self->type = tvh_context_type_find(media_type))) { tvh_stream_log(self->stream, LOG_ERR, "failed to find context type for '%s' media type", diff --git a/src/transcoding/transcode/helpers.c b/src/transcoding/transcode/helpers.c index e54e42066..025512f63 100644 --- a/src/transcoding/transcode/helpers.c +++ b/src/transcoding/transcode/helpers.c @@ -70,10 +70,6 @@ tvh_context_helper_find(struct TVHContextHelpers *list, const AVCodec *codec) { TVHContextHelper *helper = NULL; - if (!codec) { - return NULL; - } - SLIST_FOREACH(helper, list, link) { if (helper->type == codec->type && helper->id == codec->id) { return helper;