avcodec/iff: check pixfmt for rgb8 / rgbn

Fixes out of array access

Found-by: Piotr Bandurski <ami_stuff@o2.pl>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-08-10 21:59:33 +02:00
parent 9bcdb98839
commit 3539d6c63a
1 changed files with 2 additions and 2 deletions

View File

@ -849,9 +849,9 @@ static int decode_frame(AVCodecContext *avctx,
break; break;
case 4: case 4:
bytestream2_init(&gb, buf, buf_size); bytestream2_init(&gb, buf, buf_size);
if (avctx->codec_tag == MKTAG('R', 'G', 'B', '8')) if (avctx->codec_tag == MKTAG('R', 'G', 'B', '8') && avctx->pix_fmt == AV_PIX_FMT_RGB32)
decode_rgb8(&gb, s->frame->data[0], avctx->width, avctx->height, s->frame->linesize[0]); decode_rgb8(&gb, s->frame->data[0], avctx->width, avctx->height, s->frame->linesize[0]);
else if (avctx->codec_tag == MKTAG('R', 'G', 'B', 'N')) else if (avctx->codec_tag == MKTAG('R', 'G', 'B', 'N') && avctx->pix_fmt == AV_PIX_FMT_RGB444)
decode_rgbn(&gb, s->frame->data[0], avctx->width, avctx->height, s->frame->linesize[0]); decode_rgbn(&gb, s->frame->data[0], avctx->width, avctx->height, s->frame->linesize[0]);
else else
return unsupported(avctx); return unsupported(avctx);