summaryrefslogtreecommitdiff
path: root/libavcodec/pngdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-03 17:35:58 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-10-03 17:37:15 +0200
commit3e2b745020c2dbf0201fe7df3dad9e7e0b2e1bb6 (patch)
treea6731d13a52e24781f3870332a9a510e4e74f28e /libavcodec/pngdec.c
parente1c0cfaa419aa5d320540d5a1b3f8fd9b82ab7e5 (diff)
avcodec/pngdec: Check bits per pixel before setting monoblack pixel format
Fixes out of array accesses Fixes: asan_heap-oob_14dbfcf_4_asan_heap-oob_1ce5767_179_add_method_small.png Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pngdec.c')
-rw-r--r--libavcodec/pngdec.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index da91aab7cb..f3603b3cda 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -650,7 +650,7 @@ static int decode_frame(AVCodecContext *avctx,
} 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 = AV_PIX_FMT_PAL8;
- } else if (s->bit_depth == 1) {
+ } else if (s->bit_depth == 1 && s->bits_per_pixel == 1) {
avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
} else if (s->bit_depth == 8 &&
s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {