iff: check if there is extradata

Fixes #1368.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
(cherry picked from commit 8f61526978)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Paul B Mahol 2012-05-30 07:50:32 +00:00 committed by Michael Niedermayer
parent 0452ebfd4b
commit fc0d962919
1 changed files with 6 additions and 1 deletions

View File

@ -316,7 +316,12 @@ static av_cold int decode_init(AVCodecContext *avctx)
int err; int err;
if (avctx->bits_per_coded_sample <= 8) { if (avctx->bits_per_coded_sample <= 8) {
int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata); int palette_size;
if (avctx->extradata_size >= 2)
palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
else
palette_size = 0;
avctx->pix_fmt = (avctx->bits_per_coded_sample < 8) || avctx->pix_fmt = (avctx->bits_per_coded_sample < 8) ||
(avctx->extradata_size >= 2 && palette_size) ? PIX_FMT_PAL8 : PIX_FMT_GRAY8; (avctx->extradata_size >= 2 && palette_size) ? PIX_FMT_PAL8 : PIX_FMT_GRAY8;
} else if (avctx->bits_per_coded_sample <= 32) { } else if (avctx->bits_per_coded_sample <= 32) {