Commit 79888388 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/svq1enc: fix error handling/cleanup in case of ff_get_buffer() or...

avcodec/svq1enc: fix error handling/cleanup in case of ff_get_buffer() or scratchbuffer alloc failure
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 2a3af772
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment