ffmpeg | branch: master | Michael Niedermayer <[email protected]> | Sun Jan 18 
21:25:06 2015 +0100| [79888388e7c4ca596354f1c093e1c655df7824b8] | committer: 
Michael Niedermayer

avcodec/svq1enc: fix error handling/cleanup in case of ff_get_buffer() or 
scratchbuffer alloc failure

Signed-off-by: Michael Niedermayer <[email protected]>

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

 libavcodec/svq1enc.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index 552f39d..0c5971b 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -590,14 +590,20 @@ static int svq1_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
     }
 
     if (!s->current_picture->data[0]) {
-        if ((ret = ff_get_buffer(avctx, s->current_picture, 0))< 0 ||
-            (ret = ff_get_buffer(avctx, s->last_picture, 0))   < 0) {
+        if ((ret = ff_get_buffer(avctx, s->current_picture, 0)) < 0) {
             return ret;
         }
-        s->scratchbuf = av_malloc(s->current_picture->linesize[0] * 16 * 3);
     }
-    if (!s->scratchbuf)
-        return AVERROR(ENOMEM);
+    if (!s->last_picture->data[0]) {
+        if ((ret = ff_get_buffer(avctx, s->last_picture, 0)) < 0) {
+            return ret;
+        }
+    }
+    if (!s->scratchbuf) {
+        s->scratchbuf = av_malloc_array(s->current_picture->linesize[0], 16 * 
3);
+        if (!s->scratchbuf)
+            return AVERROR(ENOMEM);
+    }
 
     FFSWAP(AVFrame*, s->current_picture, s->last_picture);
 

_______________________________________________
ffmpeg-cvslog mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

Reply via email to