aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2013-01-12 19:36:27 +0100
committerReinhard Tartler <siretart@tauware.de>2013-01-12 19:36:27 +0100
commit3bc9cfe66e1a34c6d9dc45fde2a44aa38e6363ce (patch)
treef3284ed8ac1aa605db891e2e740199066dd5efde
parent910c1f2352830f1c0e7505cc96c77eac556df083 (diff)
downloadffmpeg-3bc9cfe66e1a34c6d9dc45fde2a44aa38e6363ce.tar.gz
oggdec: free the ogg streams on read_header failure
Plug an annoying memory leak on broken files. (cherry picked from commit 89b51b570daa80e6e3790fcd449fe61fc5574e07) Signed-off-by: Luca Barbato <lu_zero@gentoo.org> (cherry picked from commit 42bd6d9cf681306d14c92af97a40116fe4eb2522) Conflicts: libavformat/oggdec.c Conflicts: libavformat/oggdec.c
-rw-r--r--libavformat/oggdec.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index a28232a04e..cab6da7b13 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -492,14 +492,29 @@ static int ogg_get_length(AVFormatContext *s)
return 0;
}
-static int ogg_read_header(AVFormatContext *s, AVFormatParameters *ap)
+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;
+ int i, ret;
ogg->curidx = -1;
//linear headers seek from start
- if (ogg_get_headers (s) < 0){
- return -1;
+ ret = ogg_get_headers(s);
+ if (ret < 0) {
+ ogg_read_close(s);
+ return ret;
}
for (i = 0; i < ogg->nstreams; i++)
@@ -583,19 +598,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)
{