1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

pngdec: check bits_per_pixel for palette mode.

This fixes a 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-04-15 18:01:11 +02:00
parent c7dc19d68f
commit a63c813797

View File

@ -494,7 +494,8 @@ static int decode_frame(AVCodecContext *avctx,
} else if (s->bit_depth == 16 &&
s->color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
avctx->pix_fmt = PIX_FMT_RGBA64BE;
} else if (s->color_type == PNG_COLOR_TYPE_PALETTE) {
} else if ((s->bits_per_pixel == 1 || s->bits_per_pixel == 2 || s->bits_per_pixel == 4 || s->bits_per_pixel == 8) &&
s->color_type == PNG_COLOR_TYPE_PALETTE) {
avctx->pix_fmt = PIX_FMT_PAL8;
} else if (s->bit_depth == 1) {
avctx->pix_fmt = PIX_FMT_MONOBLACK;