[FFmpeg-cvslog] avcodec/videotoolboxenc: fix mutex/cond leak in error path

Thomas Guillem git at videolan.org
Mon Jun 18 21:48:54 EEST 2018


ffmpeg | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Jun 11 16:21:17 2018 +0200| [ce2330bdf896458131fcd00f9284c31617adcf01] | committer: Aman Gupta

avcodec/videotoolboxenc: fix mutex/cond leak in error path

The leak could happen when the vtenc_create_encoder() function failed.

Signed-off-by: Aman Gupta <aman at tmm1.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ce2330bdf896458131fcd00f9284c31617adcf01
---

 libavcodec/videotoolboxenc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 7796a685c2..9f2a71b15d 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -2473,13 +2473,14 @@ 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;
 
     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;
 



More information about the ffmpeg-cvslog mailing list