[FFmpeg-devel] [PATCH 5/9] lavf/oggdec: rework allocations in ogg_new_streams().

Clément Bœsch ubitux at gmail.com
Sat Sep 15 01:20:44 CEST 2012


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

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 05aeddd..451e392 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -169,14 +169,18 @@ 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));
+    ogg->streams = av_realloc_f(ogg->streams, ogg->nstreams,
+                                sizeof(*ogg->streams));
+    if (!ogg->streams)
+        return AVERROR(ENOMEM);
     memset (ogg->streams + idx, 0, sizeof (*ogg->streams));
     os = ogg->streams + idx;
     os->serial = serial;
     os->bufsize = DECODER_BUFFER_SIZE;
     os->buf = av_malloc(os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE);
     os->header = -1;
+    if (!os->buf)
+        return AVERROR(ENOMEM);
 
     if (new_avstream) {
         st = avformat_new_stream(s, NULL);
-- 
1.7.12



More information about the ffmpeg-devel mailing list