Commit e91fd754 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/ansi: Check x/y

This prevents out of array accesses

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent c1f2c4c3
...@@ -243,6 +243,8 @@ static int execute_code(AVCodecContext * avctx, int c) ...@@ -243,6 +243,8 @@ static int execute_code(AVCodecContext * avctx, int c)
default: default:
avpriv_request_sample(avctx, "Unsupported screen mode"); avpriv_request_sample(avctx, "Unsupported screen mode");
} }
s->x = av_clip(s->x, 0, width - FONT_WIDTH);
s->y = av_clip(s->y, 0, height - s->font_height);
if (width != avctx->width || height != avctx->height) { if (width != avctx->width || height != avctx->height) {
av_frame_unref(s->frame); av_frame_unref(s->frame);
avcodec_set_dimensions(avctx, width, height); avcodec_set_dimensions(avctx, width, height);
...@@ -336,6 +338,8 @@ static int execute_code(AVCodecContext * avctx, int c) ...@@ -336,6 +338,8 @@ static int execute_code(AVCodecContext * avctx, int c)
avpriv_request_sample(avctx, "Unknown escape code"); avpriv_request_sample(avctx, "Unknown escape code");
break; break;
} }
s->x = av_clip(s->x, 0, avctx->width - FONT_WIDTH);
s->y = av_clip(s->y, 0, avctx->height - s->font_height);
return 0; return 0;
} }
......
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