svq1enc: correctly handle memory error and allocations
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 27 Jan 2015 15:32:54 +0000 (15:32 +0000)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Tue, 3 Feb 2015 15:23:21 +0000 (15:23 +0000)
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
libavcodec/svq1enc.c

index d70bba3..f49f487 100644 (file)
@@ -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);