libavcodec/utils: Free threads on init failure
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 27 Aug 2019 15:21:00 +0000 (17:21 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 15 Sep 2019 22:04:18 +0000 (00:04 +0200)
Fixes: Multiple memleaks
Fixes: ffmpeg-memory-leak

Found-by: Francis Provencher <francis@protekresearchlab.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/utils.c

index a6a646636d6e437f6e920213ef7be43eafeaf57c..729c10a8ed6d71377c05746118d85ad94c79b0cb 100644 (file)
@@ -1029,6 +1029,9 @@ free_and_end:
          (avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP)))
         avctx->codec->close(avctx);
 
+    if (HAVE_THREADS && avctx->internal->thread_ctx)
+        ff_thread_free(avctx);
+
     if (codec->priv_class && codec->priv_data_size)
         av_opt_free(avctx->priv_data);
     av_opt_free(avctx);