summaryrefslogtreecommitdiff
path: root/libavcodec/indeo3.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-03-05 02:15:35 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-03-05 02:15:35 +0100
commite75518e18d953080409711bab291d9501625e103 (patch)
tree9db28b119bb3941ffd90d2b39f44cbe0260a735a /libavcodec/indeo3.c
parentccb76ad91f2b97009b06c22ae1b2e0234dbf26ca (diff)
indeo3: move MV check up.
This adds checking for modes >= 10. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/indeo3.c')
-rw-r--r--libavcodec/indeo3.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c
index a87252a46a..b4751c2c00 100644
--- a/libavcodec/indeo3.c
+++ b/libavcodec/indeo3.c
@@ -573,6 +573,19 @@ static int decode_cell(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
/* setup output and reference pointers */
offset = (cell->ypos << 2) * plane->pitch + (cell->xpos << 2);
block = plane->pixels[ctx->buf_sel] + offset;
+
+ if (cell->mv_ptr) {
+ mv_y = cell->mv_ptr[0];
+ mv_x = cell->mv_ptr[1];
+ if ( mv_x + 4*cell->xpos < 0
+ || mv_y + 4*cell->ypos < 0
+ || mv_x + 4*cell->xpos + 4*cell->width > plane->width
+ || mv_y + 4*cell->ypos + 4*cell->height > plane->height) {
+ av_log(avctx, AV_LOG_ERROR, "motion vector %d %d outside reference\n", mv_x + 4*cell->xpos, mv_y + 4*cell->ypos);
+ return AVERROR_INVALIDDATA;
+ }
+ }
+
if (!cell->mv_ptr) {
/* use previous line as reference for INTRA cells */
ref_block = block - plane->pitch;
@@ -584,13 +597,6 @@ static int decode_cell(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
/* set the pointer to the reference pixels for modes 0-4 INTER */
mv_y = cell->mv_ptr[0];
mv_x = cell->mv_ptr[1];
- if ( mv_x + 4*cell->xpos < 0
- || mv_y + 4*cell->ypos < 0
- || mv_x + 4*cell->xpos + 4*cell->width > plane->width
- || mv_y + 4*cell->ypos + 4*cell->height > plane->height) {
- av_log(avctx, AV_LOG_ERROR, "motion vector %d %d outside reference\n", mv_x + 4*cell->xpos, mv_y + 4*cell->ypos);
- return AVERROR_INVALIDDATA;
- }
offset += mv_y * plane->pitch + mv_x;
ref_block = plane->pixels[ctx->buf_sel ^ 1] + offset;
}