oggdec: free the ogg streams on read_header failure
Plug an annoying memory leak on broken files. (cherry picked from commit89b51b570d
) Signed-off-by: Luca Barbato <lu_zero@gentoo.org> (cherry picked from commit42bd6d9cf6
) Conflicts: libavformat/oggdec.c Conflicts: libavformat/oggdec.c
This commit is contained in:
@@ -492,14 +492,29 @@ static int ogg_get_length(AVFormatContext *s)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ogg_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
static int ogg_read_close(AVFormatContext *s)
|
||||||
{
|
{
|
||||||
struct ogg *ogg = s->priv_data;
|
struct ogg *ogg = s->priv_data;
|
||||||
int i;
|
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;
|
ogg->curidx = -1;
|
||||||
//linear headers seek from start
|
//linear headers seek from start
|
||||||
if (ogg_get_headers (s) < 0){
|
ret = ogg_get_headers(s);
|
||||||
return -1;
|
if (ret < 0) {
|
||||||
|
ogg_read_close(s);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ogg->nstreams; i++)
|
for (i = 0; i < ogg->nstreams; i++)
|
||||||
@@ -583,19 +598,6 @@ retry:
|
|||||||
return psize;
|
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,
|
static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index,
|
||||||
int64_t *pos_arg, int64_t pos_limit)
|
int64_t *pos_arg, int64_t pos_limit)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user