From 40adcf576f7d93cc46269ce73f64a1d4638ad786 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 22 Feb 2015 18:54:10 +0100 Subject: [PATCH] avformat/oggdec: Check for ost allocation failure Fixes CID1257798 Signed-off-by: Michael Niedermayer --- libavformat/oggdec.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index f19c5b1cd3..28057ad2cc 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -68,6 +68,10 @@ static int ogg_save(AVFormatContext *s) struct ogg_state *ost = av_malloc(sizeof(*ost) + (ogg->nstreams - 1) * sizeof(*ogg->streams)); int i; + + if (!ost) + return AVERROR(ENOMEM); + ost->pos = avio_tell(s->pb); ost->curidx = ogg->curidx; ost->next = ogg->state; @@ -583,6 +587,7 @@ static int ogg_get_length(AVFormatContext *s) int i; int64_t size, end; int streams_left=0; + int ret; if (!s->pb->seekable) return 0; @@ -596,7 +601,9 @@ static int ogg_get_length(AVFormatContext *s) return 0; end = size > MAX_PAGE_SIZE ? size - MAX_PAGE_SIZE : 0; - ogg_save(s); + ret = ogg_save(s); + if (ret < 0) + return ret; avio_seek(s->pb, end, SEEK_SET); ogg->page_pos = -1; @@ -618,7 +625,10 @@ static int ogg_get_length(AVFormatContext *s) ogg_restore(s, 0); - ogg_save (s); + ret = ogg_save(s); + if (ret < 0) + return ret; + avio_seek (s->pb, s->internal->data_offset, SEEK_SET); ogg_reset(s); while (streams_left > 0 && !ogg_packet(s, &i, NULL, NULL, NULL)) { -- 2.11.0