[libav-stable] bmpdec: only initialize palette for pal8.

Anton Khirnov git at libav.org
Sun Sep 16 09:47:27 CEST 2012


Module: libav
Branch: master
Commit: 8b78c2969a5b7dca939d93bf525aa2bcd737b5d9

Author:    Anton Khirnov <anton at khirnov.net>
Committer: Anton Khirnov <anton at khirnov.net>
Date:      Sun Sep 16 08:33:09 2012 +0200

bmpdec: only initialize palette for pal8.

Gray8 is not considered to be paletted, so this would cause an invalid
write.

Fixes bug 367.

CC: libav-stable at libav.org

---

 libavcodec/bmp.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c
index 299f37c..3af25cd 100644
--- a/libavcodec/bmp.c
+++ b/libavcodec/bmp.c
@@ -228,9 +228,6 @@ static int bmp_decode_frame(AVCodecContext *avctx,
     if(comp == BMP_RLE4 || comp == BMP_RLE8)
         memset(p->data[0], 0, avctx->height * p->linesize[0]);
 
-    if(depth == 4 || depth == 8)
-        memset(p->data[1], 0, 1024);
-
     if(height > 0){
         ptr = p->data[0] + (avctx->height - 1) * p->linesize[0];
         linesize = -p->linesize[0];
@@ -241,6 +238,9 @@ static int bmp_decode_frame(AVCodecContext *avctx,
 
     if(avctx->pix_fmt == PIX_FMT_PAL8){
         int colors = 1 << depth;
+
+        memset(p->data[1], 0, 1024);
+
         if(ihsize >= 36){
             int t;
             buf = buf0 + 46;



More information about the libav-stable mailing list