Browse Source

oggdec: make sure the private parse data is cleaned up

tags/n1.2
Luca Barbato 12 years ago
parent
commit
d894f74762
3 changed files with 16 additions and 0 deletions
  1. +4
    -0
      libavformat/oggdec.c
  2. +1
    -0
      libavformat/oggdec.h
  3. +11
    -0
      libavformat/oggparsevorbis.c

+ 4
- 0
libavformat/oggdec.c View File

@@ -533,6 +533,10 @@ static int ogg_read_close(AVFormatContext *s)


for (i = 0; i < ogg->nstreams; i++) { for (i = 0; i < ogg->nstreams; i++) {
av_free(ogg->streams[i].buf); av_free(ogg->streams[i].buf);
if (ogg->streams[i].codec &&
ogg->streams[i].codec->cleanup) {
ogg->streams[i].codec->cleanup(s, i);
}
av_free(ogg->streams[i].private); av_free(ogg->streams[i].private);
} }
av_free(ogg->streams); av_free(ogg->streams);


+ 1
- 0
libavformat/oggdec.h View File

@@ -55,6 +55,7 @@ struct ogg_codec {
* Number of expected headers * Number of expected headers
*/ */
int nb_header; int nb_header;
void (*cleanup)(AVFormatContext *s, int idx);
}; };


struct ogg_stream { struct ogg_stream {


+ 11
- 0
libavformat/oggparsevorbis.c View File

@@ -192,6 +192,16 @@ fixup_vorbis_headers(AVFormatContext * as, struct oggvorbis_private *priv,
return offset; return offset;
} }


static int vorbis_cleanup(AVFormatContext *s, int idx)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
struct oggvorbis_private *priv = os->private;
int i;
if (os->private)
for (i = 0; i < 3; i++)
av_freep(&priv->packet[i]);
}


static int static int
vorbis_header (AVFormatContext * s, int idx) vorbis_header (AVFormatContext * s, int idx)
@@ -359,5 +369,6 @@ const struct ogg_codec ff_vorbis_codec = {
.magicsize = 7, .magicsize = 7,
.header = vorbis_header, .header = vorbis_header,
.packet = vorbis_packet, .packet = vorbis_packet,
.cleanup= vorbis_cleanup,
.nb_header = 3, .nb_header = 3,
}; };

Loading…
Cancel
Save