avcodec/mpegvideo: Reset bitstream_buffer_size on allocation failure
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 28 May 2015 22:33:18 +0000 (00:33 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 28 May 2015 22:33:18 +0000 (00:33 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/mpeg4videodec.c
libavcodec/mpegvideo.c

index 9ef65ff..41caac6 100644 (file)
@@ -2670,8 +2670,10 @@ int ff_mpeg4_frame_end(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
             av_fast_padded_malloc(&s->bitstream_buffer,
                            &s->allocated_bitstream_buffer_size,
                            buf_size - current_pos);
-            if (!s->bitstream_buffer)
+            if (!s->bitstream_buffer) {
+                s->bitstream_buffer_size = 0;
                 return AVERROR(ENOMEM);
+            }
             memcpy(s->bitstream_buffer, buf + current_pos,
                    buf_size - current_pos);
             s->bitstream_buffer_size = buf_size - current_pos;
index 5fa4cb6..e798565 100644 (file)
@@ -1049,8 +1049,10 @@ do {\
             av_fast_malloc(&s->bitstream_buffer,
                            &s->allocated_bitstream_buffer_size,
                            s1->allocated_bitstream_buffer_size);
-            if (!s->bitstream_buffer)
+            if (!s->bitstream_buffer) {
+                s->bitstream_buffer_size = 0;
                 return AVERROR(ENOMEM);
+            }
         }
         s->bitstream_buffer_size = s1->bitstream_buffer_size;
         memcpy(s->bitstream_buffer, s1->bitstream_buffer,