Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-11-26 01:30:22 +0400
committerMichael Niedermayer <michaelni@gmx.at>2012-11-26 01:33:54 +0400
commit579d21f777ea1cb51a47f38b4429742837b05404 (patch)
tree963f558ea9d7819e06526a90ec78ae40ee3e0e85 /libavcodec/targa.c
parente55c3857d20ba015e4914c2e80fcab037af0799d (diff)
tga: check palette size earlier.
Fixes Ticket1895 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/targa.c')
-rw-r--r--libavcodec/targa.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavcodec/targa.c b/libavcodec/targa.c
index 67ed0d5b33..d761078cfe 100644
--- a/libavcodec/targa.c
+++ b/libavcodec/targa.c
@@ -172,6 +172,11 @@ static int decode_frame(AVCodecContext *avctx,
if (s->picture.data[0])
avctx->release_buffer(avctx, &s->picture);
+ if (colors && (colors + first_clr) > 256) {
+ av_log(avctx, AV_LOG_ERROR, "Incorrect palette: %i colors with offset %i\n", colors, first_clr);
+ return AVERROR_INVALIDDATA;
+ }
+
if ((ret = av_image_check_size(w, h, 0, avctx)))
return ret;
if (w != avctx->width || h != avctx->height)
@@ -194,10 +199,6 @@ static int decode_frame(AVCodecContext *avctx,
if (colors) {
int pal_size, pal_sample_size;
- if ((colors + first_clr) > 256) {
- av_log(avctx, AV_LOG_ERROR, "Incorrect palette: %i colors with offset %i\n", colors, first_clr);
- return AVERROR_INVALIDDATA;
- }
switch (csize) {
case 32: pal_sample_size = 4; break;
case 24: pal_sample_size = 3; break;