riff: Fix potential memleak.
authorAlex Converse <alex.converse@gmail.com>
Thu, 9 Jun 2011 16:50:38 +0000 (09:50 -0700)
committerAlex Converse <alex.converse@gmail.com>
Thu, 9 Jun 2011 17:12:50 +0000 (10:12 -0700)
Make ff_get_wav_header() free existing extradata before allocing a new
buffer.

libavformat/riff.c

index e17980a00a22bd9ecadd15b98176c03a905f6bec..fe6cc5505517588c17fa5c2fcafb6eb054da7a1c 100644 (file)
@@ -509,6 +509,7 @@ int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
         }
         codec->extradata_size = cbSize;
         if (cbSize > 0) {
+            av_free(codec->extradata);
             codec->extradata = av_mallocz(codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
             if (!codec->extradata)
                 return AVERROR(ENOMEM);