aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/svq1enc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-01-18 21:17:18 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-01-18 21:21:44 +0100
commit2a3af77284412b56eb0085f4b97d9db5aa04a64f (patch)
tree6bada2eb1b188d2969140fa1c5f3d227d761f827 /libavcodec/svq1enc.c
parent65b83ce01b94eae944290c11257799a9288f2d4c (diff)
downloadffmpeg-2a3af77284412b56eb0085f4b97d9db5aa04a64f.tar.gz
avcodec/svq1enc: Check memory allocations
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/svq1enc.c')
-rw-r--r--libavcodec/svq1enc.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index 2a0d78043a..552f39d381 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -301,6 +301,8 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
s->motion_val16[plane] = av_mallocz((s->m.mb_stride *
(block_height + 2) + 1) *
2 * sizeof(int16_t));
+ if (!s->motion_val8[plane] || !s->motion_val16[plane])
+ return AVERROR(ENOMEM);
}
s->m.mb_type = s->mb_type;
@@ -555,6 +557,12 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
s->y_block_height * sizeof(int32_t));
s->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
+ if (!s->m.me.scratchpad || !s->m.me.map || !s->m.me.score_map ||
+ !s->mb_type || !s->dummy) {
+ svq1_encode_end(avctx);
+ return AVERROR(ENOMEM);
+ }
+
if (ARCH_PPC)
ff_svq1enc_init_ppc(s);
if (ARCH_X86)
@@ -588,6 +596,8 @@ static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
s->scratchbuf = av_malloc(s->current_picture->linesize[0] * 16 * 3);
}
+ if (!s->scratchbuf)
+ return AVERROR(ENOMEM);
FFSWAP(AVFrame*, s->current_picture, s->last_picture);