cafdec: free extradata before allocating it
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Tue, 12 May 2015 22:22:03 +0000 (00:22 +0200)
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Wed, 13 May 2015 18:11:37 +0000 (20:11 +0200)
This fixes a memleak if read_kuki_chunk is executed more than once.

Reviewed-by: Carl Eugen Hoyos <cehoyos@ag.or.at>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
libavformat/cafdec.c

index abbb353..cc6ed0c 100644 (file)
@@ -134,6 +134,7 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
             return AVERROR_INVALIDDATA;
         }
 
+        av_freep(&st->codec->extradata);
         if (ff_alloc_extradata(st->codec, ALAC_HEADER))
             return AVERROR(ENOMEM);
 
@@ -166,6 +167,7 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
             avio_skip(pb, size - ALAC_NEW_KUKI);
         }
     } else {
+        av_freep(&st->codec->extradata);
         if (ff_get_extradata(st->codec, pb, size) < 0)
             return AVERROR(ENOMEM);
     }