[FFmpeg-cvslog] oggdec: check memory allocation

Luca Barbato git at videolan.org
Thu Jan 17 02:41:29 CET 2013


ffmpeg | branch: release/0.10 | Luca Barbato <lu_zero at gentoo.org> | Sat Dec 22 17:58:24 2012 +0100| [6eebba08e1888371637c2f86878130f9e7a30732] | committer: Reinhard Tartler

oggdec: check memory allocation

(cherry picked from commit ba064ebe48376e199f353ef0b335ed8a39c638c5)

Conflicts:

	libavformat/oggdec.c

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

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

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 950308b..42a1a55 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -161,8 +161,13 @@ static int ogg_new_stream(AVFormatContext *s, uint32_t serial, int new_avstream)
     AVStream *st;
     struct ogg_stream *os;
 
-    ogg->streams = av_realloc (ogg->streams,
-                               ogg->nstreams * sizeof (*ogg->streams));
+    os = av_realloc (ogg->streams, ogg->nstreams * sizeof (*ogg->streams));
+
+    if (!os)
+        return AVERROR(ENOMEM);
+
+    ogg->streams = os;
+
     memset (ogg->streams + idx, 0, sizeof (*ogg->streams));
     os = ogg->streams + idx;
     os->serial = serial;
@@ -297,6 +302,8 @@ static int ogg_read_page(AVFormatContext *s, int *str)
 
     if (os->bufsize - os->bufpos < size){
         uint8_t *nb = av_malloc ((os->bufsize *= 2) + FF_INPUT_BUFFER_PADDING_SIZE);
+        if (!nb)
+            return AVERROR(ENOMEM);
         memcpy (nb, os->buf, os->bufpos);
         av_free (os->buf);
         os->buf = nb;



More information about the ffmpeg-cvslog mailing list