[FFmpeg-cvslog] avcodec/mpegvideo: Check pointer when allocation fail

Roman Savchenko git at videolan.org
Fri May 29 01:56:31 CEST 2015


ffmpeg | branch: master | Roman Savchenko <gmstima at gmail.com> | Thu May 28 18:25:57 2015 +0300| [e5d1152ccc301c5e4345fd9e70eaab899d8a19c2] | committer: Michael Niedermayer

avcodec/mpegvideo: Check pointer when allocation fail

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

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

 libavcodec/mpegvideo.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 5b9a9b9..5fa4cb6 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1045,11 +1045,14 @@ do {\
 
     if (s1->bitstream_buffer) {
         if (s1->bitstream_buffer_size +
-            FF_INPUT_BUFFER_PADDING_SIZE > s->allocated_bitstream_buffer_size)
+            FF_INPUT_BUFFER_PADDING_SIZE > s->allocated_bitstream_buffer_size) {
             av_fast_malloc(&s->bitstream_buffer,
                            &s->allocated_bitstream_buffer_size,
                            s1->allocated_bitstream_buffer_size);
-            s->bitstream_buffer_size = s1->bitstream_buffer_size;
+            if (!s->bitstream_buffer)
+                return AVERROR(ENOMEM);
+        }
+        s->bitstream_buffer_size = s1->bitstream_buffer_size;
         memcpy(s->bitstream_buffer, s1->bitstream_buffer,
                s1->bitstream_buffer_size);
         memset(s->bitstream_buffer + s->bitstream_buffer_size, 0,



More information about the ffmpeg-cvslog mailing list