From: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Sep 2025 12:15:37 +0000 (+0000) Subject: Fix at earliest point: check for NULL codec before opening encoder X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F1933%2Fhead;p=thirdparty%2Ftvheadend.git Fix at earliest point: check for NULL codec before opening encoder Co-authored-by: Flole998 <9951871+Flole998@users.noreply.github.com> --- diff --git a/src/transcoding/codec/codec.c b/src/transcoding/codec/codec.c index 38f78c8ca..6e5d1e3e7 100644 --- a/src/transcoding/codec/codec.c +++ b/src/transcoding/codec/codec.c @@ -231,7 +231,7 @@ tvh_codec_get_type_string(TVHCodec *self) const AVCodec * tvh_codec_get_codec(TVHCodec *self) { - return self ? self->codec : NULL; + return self->codec; } diff --git a/src/transcoding/transcode/context.c b/src/transcoding/transcode/context.c index 6d939e8f0..b30492dca 100644 --- a/src/transcoding/transcode/context.c +++ b/src/transcoding/transcode/context.c @@ -414,6 +414,11 @@ tvh_context_encode(TVHContext *self, AVFrame *avframe) int ret = 0; if (!avcodec_is_open(self->oavctx)) { + // Check if we have a valid codec before attempting to open + if (!self->oavctx->codec) { + tvh_context_log(self, LOG_ERR, "cannot open encoder: no codec available"); + return -1; + } ret = tvh_context_open(self, OPEN_ENCODER); } if (!ret && !(ret = tvh_context_push_frame(self, avframe))) {