[FFmpeg-cvslog] svq1enc: correctly handle memory error and allocations

Michael Niedermayer git at videolan.org
Tue Feb 3 22:50:33 CET 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Jan 27 15:32:54 2015 +0000| [6f7a32839d1b913be8170e91c3ac9816b314da21] | committer: Vittorio Giovara

svq1enc: correctly handle memory error and allocations

Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>

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

 libavcodec/svq1enc.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index d70bba3..f49f487 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -583,10 +583,16 @@ static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         ret = ff_get_buffer(avctx, s->current_picture, 0);
         if (ret < 0)
             return ret;
+    }
+    if (!s->last_picture->data[0]) {
         ret = ff_get_buffer(avctx, s->last_picture, 0);
         if (ret < 0)
             return ret;
+    }
+    if (!s->scratchbuf) {
         s->scratchbuf = av_malloc(s->current_picture->linesize[0] * 16 * 2);
+        if (!s->scratchbuf)
+            return AVERROR(ENOMEM);
     }
 
     FFSWAP(AVFrame*, s->current_picture, s->last_picture);



More information about the ffmpeg-cvslog mailing list