Module: libav
Branch: master
Commit: ba064ebe48376e199f353ef0b335ed8a39c638c5

Author:    Luca Barbato <[email protected]>
Committer: Luca Barbato <[email protected]>
Date:      Sat Dec 22 17:58:24 2012 +0100

oggdec: check memory allocation

---

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

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index a1c126a..07af5cf 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -160,8 +160,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;
@@ -305,6 +310,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;

_______________________________________________
libav-commits mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-commits

Reply via email to