diff options
author | Peter Ross <pross@xvid.org> | 2012-10-14 21:50:09 +1100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-10-14 15:56:36 +0200 |
commit | 0ea55365b91c250012ac8a80be5f0ebacd4fd55d (patch) | |
tree | 4725acfa11a8d5baa5ae33e9caa4c17901d31069 /libavcodec/ansi.c | |
parent | d6f6a7557c8d25bb9943b4d3390550a9cffb918b (diff) | |
download | ffmpeg-0ea55365b91c250012ac8a80be5f0ebacd4fd55d.tar.gz |
ansi: by design nb_args may exceed the size of the args array, so guard accordingly
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/ansi.c')
-rw-r--r-- | libavcodec/ansi.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libavcodec/ansi.c b/libavcodec/ansi.c index 6bfd08ce3e..d84b395301 100644 --- a/libavcodec/ansi.c +++ b/libavcodec/ansi.c @@ -299,7 +299,7 @@ static int execute_code(AVCodecContext * avctx, int c) s->attributes |= 1 << (m - 1); } else if (m >= 30 && m <= 37) { s->fg = ansi_to_cga[m - 30]; - } else if (m == 38 && i + 2 < s->nb_args && s->args[i + 1] == 5 && s->args[i + 2] < 256) { + } else if (m == 38 && i + 2 < FFMIN(s->nb_args, MAX_NB_ARGS) && s->args[i + 1] == 5 && s->args[i + 2] < 256) { int index = s->args[i + 2]; s->fg = index < 16 ? ansi_to_cga[index] : index; i += 2; @@ -307,7 +307,7 @@ static int execute_code(AVCodecContext * avctx, int c) s->fg = ansi_to_cga[DEFAULT_FG_COLOR]; } else if (m >= 40 && m <= 47) { s->bg = ansi_to_cga[m - 40]; - } else if (m == 48 && i + 2 < s->nb_args && s->args[i + 1] == 5 && s->args[i + 2] < 256) { + } else if (m == 48 && i + 2 < FFMIN(s->nb_args, MAX_NB_ARGS) && s->args[i + 1] == 5 && s->args[i + 2] < 256) { int index = s->args[i + 2]; s->bg = index < 16 ? ansi_to_cga[index] : index; i += 2; |