[FFmpeg-devel] [PATCH 2/2] avcodec/pthread_frame: Only attempt to close decoders which have allocated private data

Michael Niedermayer michael at niedermayer.cc
Fri Mar 19 17:26:52 EET 2021


Fixes: Null pointer dereference
Fixes: ff_h264_remove_all_refs.mp4

Found-by: Rafael Dutra <rafael.dutra at cispa.de>
Tested-by: Rafael Dutra <rafael.dutra at cispa.de>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/pthread_frame.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 7bcb9a7bcc..048e535cb6 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -708,7 +708,7 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
             pthread_join(p->thread, NULL);
         p->thread_init=0;
 
-        if (codec->close && p->avctx)
+        if (codec->close && p->avctx && p->avctx->priv_data)
             codec->close(p->avctx);
 
 #if FF_API_THREAD_SAFE_CALLBACKS
-- 
2.17.1



More information about the ffmpeg-devel mailing list