avcodec/videotoolboxenc: fix mutex/cond leak in error path
authorThomas Guillem <thomas@gllm.fr>
Mon, 11 Jun 2018 14:21:17 +0000 (16:21 +0200)
committerAman Gupta <aman@tmm1.net>
Mon, 18 Jun 2018 18:48:05 +0000 (11:48 -0700)
The leak could happen when the vtenc_create_encoder() function failed.

Signed-off-by: Aman Gupta <aman@tmm1.net>
libavcodec/videotoolboxenc.c

index 7796a68..9f2a71b 100644 (file)
@@ -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;