PR #25285 opened by Forgejo_Fairy
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25285
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25285.patch

Addresses #24598.

Move the NULL check in `tf_start_inference()` before all reads through the 
request and use a NULL logging context for that error path. This makes the 
documented `AVERROR(EINVAL)` return reachable.

Validation: an isolated build of the function extracted from master segfaulted 
on NULL at `-O0` before the change. With this change, NULL returned `-EINVAL` 
at `-O0` and `-O2`, while a valid request reached the TensorFlow session stub 
and returned success. `git diff --check` passed. The complete TensorFlow 
backend was not built because its development package was unavailable.


>From cf157f16ebed35871c2d86ce2d9e38cba090a264 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 21 Oct 2026 03:35:21 +0000
Subject: [PATCH] avfilter/dnn_backend_tf: validate inference request before
 dereference

Check the request before reading its fields and use a context-free log for
the NULL case. This makes the documented EINVAL return reachable.

Assisted-by: Fairy
---
 libavfilter/dnn/dnn_backend_tf.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c
index c292a14efe9..6882e0bb311 100644
--- a/libavfilter/dnn/dnn_backend_tf.c
+++ b/libavfilter/dnn/dnn_backend_tf.c
@@ -141,16 +141,21 @@ static TFInferRequest *tf_create_inference_request(void)
 static int tf_start_inference(void *args)
 {
     TFRequestItem *request = args;
-    TFInferRequest *infer_request = request->infer_request;
-    LastLevelTaskItem *lltask = request->lltask;
-    TaskItem *task = lltask->task;
-    TFModel *tf_model = task->model;
+    TFInferRequest *infer_request;
+    LastLevelTaskItem *lltask;
+    TaskItem *task;
+    TFModel *tf_model;
 
     if (!request) {
-        av_log(tf_model->ctx, AV_LOG_ERROR, "TFRequestItem is NULL\n");
+        av_log(NULL, AV_LOG_ERROR, "TFRequestItem is NULL\n");
         return AVERROR(EINVAL);
     }
 
+    infer_request = request->infer_request;
+    lltask = request->lltask;
+    task = lltask->task;
+    tf_model = task->model;
+
     TF_SessionRun(tf_model->session, NULL,
                   infer_request->tf_input, &infer_request->input_tensor, 1,
                   infer_request->tf_outputs, infer_request->output_tensors,
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to