[FFmpeg-cvslog] avformat/oggdec: Check for ost allocation failure

Michael Niedermayer git at videolan.org
Sun Feb 22 19:43:44 CET 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Feb 22 18:54:10 2015 +0100| [40adcf576f7d93cc46269ce73f64a1d4638ad786] | committer: Michael Niedermayer

avformat/oggdec: Check for ost allocation failure

Fixes CID1257798
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=40adcf576f7d93cc46269ce73f64a1d4638ad786
---

 libavformat/oggdec.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index f19c5b1..28057ad 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)) {



More information about the ffmpeg-cvslog mailing list