[FFmpeg-cvslog] avcodec/utils: Also free encoder extradata on avcodec_open2() error

Andreas Rheinhardt git at videolan.org
Thu Oct 1 15:13:50 EEST 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sat Sep 26 11:18:13 2020 +0200| [b8e0ceda11f7a12d763c6a744943347fc808b8b7] | committer: Andreas Rheinhardt

avcodec/utils: Also free encoder extradata on avcodec_open2() error

It is owned by libavcodec for encoders.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

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

 libavcodec/utils.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 05064b560f..a976ceb260 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1034,11 +1034,15 @@ free_and_end:
         av_opt_free(avctx->priv_data);
     av_opt_free(avctx);
 
+    if (av_codec_is_encoder(avctx->codec)) {
 #if FF_API_CODED_FRAME
 FF_DISABLE_DEPRECATION_WARNINGS
     av_frame_free(&avctx->coded_frame);
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
+        av_freep(&avctx->extradata);
+        avctx->extradata_size = 0;
+    }
 
     av_dict_free(&tmp);
     av_freep(&avctx->priv_data);



More information about the ffmpeg-cvslog mailing list