[FFmpeg-cvslog] avcodec/audiotoolboxdec: always use a copy of the AVCodecContext extradata

James Almer git at videolan.org
Wed Sep 6 19:05:15 EEST 2017


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Thu May 25 11:00:47 2017 -0300| [7273e234dee5dfeee67cc365a8f7fa0b8211127c] | committer: James Almer

avcodec/audiotoolboxdec: always use a copy of the AVCodecContext extradata

Fixes memleaks introduced by 954e2b3d34b7c2d82871254f07e2f8a39bc451cb

Signed-off-by: James Almer <jamrial at gmail.com>

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

 libavcodec/audiotoolboxdec.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
index a8655f0421..d499a0afc8 100644
--- a/libavcodec/audiotoolboxdec.c
+++ b/libavcodec/audiotoolboxdec.c
@@ -399,8 +399,13 @@ static av_cold int ffat_create_decoder(AVCodecContext *avctx, AVPacket *pkt)
 static av_cold int ffat_init_decoder(AVCodecContext *avctx)
 {
     ATDecodeContext *at = avctx->priv_data;
-    at->extradata = avctx->extradata;
-    at->extradata_size = avctx->extradata_size;
+    if (avctx->extradata_size) {
+        at->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
+        if (!at->extradata)
+            return AVERROR(ENOMEM);
+        at->extradata_size = avctx->extradata_size;
+        memcpy(at->extradata, avctx->extradata, avctx->extradata_size);
+    }
 
     if ((avctx->channels && avctx->sample_rate) || ffat_usable_extradata(avctx))
         return ffat_create_decoder(avctx, NULL);
@@ -599,6 +604,7 @@ static av_cold int ffat_close_decoder(AVCodecContext *avctx)
     av_packet_unref(&at->new_in_pkt);
     av_packet_unref(&at->in_pkt);
     av_free(at->decoded_data);
+    av_free(at->extradata);
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list