diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2013-01-04 15:44:02 +0100 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2013-01-06 17:59:54 +0100 |
commit | 89b51b570daa80e6e3790fcd449fe61fc5574e07 (patch) | |
tree | 57882bd42645c9d774101e6394ad42030a390e0d /libavformat | |
parent | a0c5917f86a6ff0d91d7f9af71afca0d43c14825 (diff) | |
download | ffmpeg-89b51b570daa80e6e3790fcd449fe61fc5574e07.tar.gz |
oggdec: free the ogg streams on read_header failure
Plug an annoying memory leak on broken files.
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/oggdec.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 07af5cf9d0..a6cd31c514 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -526,6 +526,19 @@ static int ogg_get_length(AVFormatContext *s) return 0; } +static int ogg_read_close(AVFormatContext *s) +{ + struct ogg *ogg = s->priv_data; + int i; + + for (i = 0; i < ogg->nstreams; i++) { + av_free(ogg->streams[i].buf); + av_free(ogg->streams[i].private); + } + av_free(ogg->streams); + return 0; +} + static int ogg_read_header(AVFormatContext *s) { struct ogg *ogg = s->priv_data; @@ -533,8 +546,10 @@ static int ogg_read_header(AVFormatContext *s) ogg->curidx = -1; //linear headers seek from start ret = ogg_get_headers(s); - if (ret < 0) + if (ret < 0) { + ogg_read_close(s); return ret; + } for (i = 0; i < ogg->nstreams; i++) if (ogg->streams[i].header < 0) @@ -619,19 +634,6 @@ retry: return psize; } -static int ogg_read_close(AVFormatContext *s) -{ - struct ogg *ogg = s->priv_data; - int i; - - for (i = 0; i < ogg->nstreams; i++) { - av_free(ogg->streams[i].buf); - av_free(ogg->streams[i].private); - } - av_free(ogg->streams); - return 0; -} - static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index, int64_t *pos_arg, int64_t pos_limit) { |