truemotion2: check motion vectors for validity

Fixes out of array read

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-03-04 07:09:00 +01:00
parent 39a3a53b66
commit 2b693546ad

View File

@ -638,6 +638,11 @@ static inline void tm2_motion_block(TM2Context *ctx, AVFrame *pic, int bx, int b
mx = GET_TOK(ctx, TM2_MOT); mx = GET_TOK(ctx, TM2_MOT);
my = GET_TOK(ctx, TM2_MOT); my = GET_TOK(ctx, TM2_MOT);
if (4*bx+mx<0 || 4*by+my<0 || 4*bx+mx+4 > ctx->avctx->width || 4*by+my+4 > ctx->avctx->height) {
av_log(0,0, "MV out of picture\n");
return;
}
Yo += my * oYstride + mx; Yo += my * oYstride + mx;
Uo += (my >> 1) * oUstride + (mx >> 1); Uo += (my >> 1) * oUstride + (mx >> 1);
Vo += (my >> 1) * oVstride + (mx >> 1); Vo += (my >> 1) * oVstride + (mx >> 1);