[FFmpeg-devel] [PATCH] lavc/videotoolbox: validate vt context in the decoder callback

Alessandro Di Nepi alessandro.dinepi at gmail.com
Sun Nov 27 19:33:44 EET 2022


The commit d7f4ad88a0df3c1339e142957bf2c40cd056b8ce introduced a race
condition where the passed opaque pointer reference might be NULL,
when the decoding process starts.
This patch checks that vtctx has a value before accessing it.

This patch fixes #10079.

Signed-off-by: Alessandro Di Nepi <alessandro.dinepi at gmail.com>
---
 libavcodec/videotoolbox.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 1b1be8ddb4..615e2b087a 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -692,6 +692,11 @@ static void videotoolbox_decoder_callback(void *opaque,
 {
     VTContext *vtctx = opaque;
 
+    if (!vtctx) {
+        av_log(NULL, AV_LOG_WARNING, "vt decoder cb: vt context is null");
+        return;
+    }
+
     if (vtctx->frame) {
         CVPixelBufferRelease(vtctx->frame);
         vtctx->frame = NULL;
-- 
2.37.1 (Apple Git-137.1)



More information about the ffmpeg-devel mailing list