]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Fix at earliest point: check for NULL codec before opening encoder copilot/fix-1927 1933/head
authorcopilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Tue, 23 Sep 2025 12:15:37 +0000 (12:15 +0000)
committercopilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Tue, 23 Sep 2025 12:15:37 +0000 (12:15 +0000)
Co-authored-by: Flole998 <9951871+Flole998@users.noreply.github.com>
src/transcoding/codec/codec.c
src/transcoding/transcode/context.c

index 38f78c8cac247da8fba25466dfb9d5fec0d8ece7..6e5d1e3e78f8031e2701cba2a313cfc74e96237e 100644 (file)
@@ -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;
 }
 
 
index 6d939e8f034e434cb0299f65d7e406cce35006e6..b30492dcae63759fe85209d917dba29c86a2aeb0 100644 (file)
@@ -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))) {