]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/videotoolboxenc: fix use after destroy
authorZhao Zhili <zhilizhao@tencent.com>
Wed, 26 Aug 2020 21:38:45 +0000 (05:38 +0800)
committerRick Kern <kernrj@gmail.com>
Tue, 29 Sep 2020 01:46:23 +0000 (21:46 -0400)
The lock is used in clear_frame_queue().

Signed-off-by: Rick Kern <kernrj@gmail.com>
libavcodec/videotoolboxenc.c

index 7c87b6865c37fa27fb5556b723e1dfcbbbe0aab2..ea1384523212f86ca94644406abd6011defd42aa 100644 (file)
@@ -2492,14 +2492,17 @@ static av_cold int vtenc_close(AVCodecContext *avctx)
 {
     VTEncContext *vtctx = avctx->priv_data;
 
-    pthread_cond_destroy(&vtctx->cv_sample_sent);
-    pthread_mutex_destroy(&vtctx->lock);
-
-    if(!vtctx->session) return 0;
+    if(!vtctx->session) {
+        pthread_cond_destroy(&vtctx->cv_sample_sent);
+        pthread_mutex_destroy(&vtctx->lock);
+        return 0;
+    }
 
     VTCompressionSessionCompleteFrames(vtctx->session,
                                        kCMTimeIndefinite);
     clear_frame_queue(vtctx);
+    pthread_cond_destroy(&vtctx->cv_sample_sent);
+    pthread_mutex_destroy(&vtctx->lock);
     CFRelease(vtctx->session);
     vtctx->session = NULL;