From 540c5220ffafce9038b1f0c96cb02382d0ab126e Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 27 May 2008 23:41:10 +0000 Subject: [PATCH] Check dia size a little more. Fixes CID80. Originally committed as revision 13481 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/motion_est.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 54bc93da38..b97b441305 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -235,6 +235,12 @@ void ff_init_me(MpegEncContext *s){ MotionEstContext * const c= &s->me; int cache_size= FFMIN(ME_MAP_SIZE>>ME_MAP_SHIFT, 1<avctx->dia_size)&255, FFABS(s->avctx->pre_dia_size)&255); + + if(FFMIN(s->avctx->dia_size, s->avctx->pre_dia_size) < -ME_MAP_SIZE){ + av_log(s->avctx, AV_LOG_ERROR, "ME_MAP size is too small for SAB diamond\n"); + return -1; + } + c->avctx= s->avctx; if(cache_size < 2*dia_size && !c->stride){