summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-03 17:35:58 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-03-12 00:47:04 +0100
commit7a5590ef4282e19d48d70cba0bc4628c13ec6fd8 (patch)
tree9be353e3d28d9e866f3f1a79d612d96daab33039
parent73962e677d871fa0dde5385ee04ea07c048d8864 (diff)
downloadffmpeg-7a5590ef4282e19d48d70cba0bc4628c13ec6fd8.tar.gz
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> (cherry picked from commit 3e2b745020c2dbf0201fe7df3dad9e7e0b2e1bb6) Conflicts: 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 9afa0932e1..6a4953057e 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -463,7 +463,7 @@ static int decode_frame(AVCodecContext *avctx,
} else if (s->bit_depth == 16 &&
s->color_type == PNG_COLOR_TYPE_RGB) {
avctx->pix_fmt = PIX_FMT_RGB48BE;
- } else if (s->bit_depth == 1) {
+ } else if (s->bit_depth == 1 && s->bits_per_pixel == 1) {
avctx->pix_fmt = PIX_FMT_MONOBLACK;
} else if (s->bit_depth == 8 &&
s->color_type == PNG_COLOR_TYPE_PALETTE) {