diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2013-01-04 16:05:51 +0100 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2013-01-07 09:00:09 +0100 |
commit | c01be297ce5ac244d79a7b287f7fa050de113a14 (patch) | |
tree | c6a1f4d3f8ad72cdd877000c687f8bd0600f76cb | |
parent | 42bd6d9cf681306d14c92af97a40116fe4eb2522 (diff) | |
download | ffmpeg-c01be297ce5ac244d79a7b287f7fa050de113a14.tar.gz |
oggdec: make sure the private parse data is cleaned up
(cherry picked from commit d894f74762bc95310ba23f804b7ba8dffc8f6646)
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
-rw-r--r-- | libavformat/oggdec.c | 4 | ||||
-rw-r--r-- | libavformat/oggdec.h | 1 | ||||
-rw-r--r-- | libavformat/oggparsevorbis.c | 11 |
3 files changed, 16 insertions, 0 deletions
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index a6cd31c514..d8f89b8f80 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -533,6 +533,10 @@ static int ogg_read_close(AVFormatContext *s) for (i = 0; i < ogg->nstreams; i++) { 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); diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h index bb7b345934..d11ff9f591 100644 --- a/libavformat/oggdec.h +++ b/libavformat/oggdec.h @@ -55,6 +55,7 @@ struct ogg_codec { * Number of expected headers */ int nb_header; + void (*cleanup)(AVFormatContext *s, int idx); }; struct ogg_stream { diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c index 396a3e3ea7..fbe6c4fb41 100644 --- a/libavformat/oggparsevorbis.c +++ b/libavformat/oggparsevorbis.c @@ -192,6 +192,16 @@ fixup_vorbis_headers(AVFormatContext * as, struct oggvorbis_private *priv, 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 vorbis_header (AVFormatContext * s, int idx) @@ -359,5 +369,6 @@ const struct ogg_codec ff_vorbis_codec = { .magicsize = 7, .header = vorbis_header, .packet = vorbis_packet, + .cleanup= vorbis_cleanup, .nb_header = 3, }; |