diff mbox series

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

Message ID cc306167-9446-405a-9dba-d665f5670908@Spark
State New
Headers show
Series [FFmpeg-devel] lavc/videotoolbox: validate vt context in the decoder callback | expand

Checks

Context Check Description
yinshiyou/configure_loongarch64 warning Failed to apply patch
andriy/configure_x86 warning Failed to apply patch

Commit Message

Alessandro Di Nepi Nov. 27, 2022, 4:21 p.m. UTC
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@gmail.com>
---
 libavcodec/videotoolbox.c | 5 +++++
 1 file changed, 5 insertions(+)

--
2.37.1 (Apple Git-137.1)
diff mbox series

Patch

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;