[libav-commits] dds: disable palette flag for compressed images

Andreas Cadhalpun git at libav.org
Tue Nov 17 17:01:33 CET 2015


Module: libav
Branch: master
Commit: 0a8bff788b0a9f96b863f0e836a235cb1d223f55

Author:    Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
Committer: Vittorio Giovara <vittorio.giovara at gmail.com>
Date:      Fri Nov 13 21:48:27 2015 +0100

dds: disable palette flag for compressed images

Having both is not valid and can cause a NULL pointer dereference of
frame->data[1] later.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>

---

 libavcodec/dds.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/dds.c b/libavcodec/dds.c
index ea58da0..3b7e7f6 100644
--- a/libavcodec/dds.c
+++ b/libavcodec/dds.c
@@ -141,6 +141,12 @@ static int parse_pixel_format(AVCodecContext *avctx)
     normal_map      = flags & DDPF_NORMALMAP;
     fourcc = bytestream2_get_le32(gbc);
 
+    if (ctx->compressed && ctx->paletted) {
+        av_log(avctx, AV_LOG_WARNING,
+               "Disabling invalid palette flag for compressed dds.\n");
+        ctx->paletted = 0;
+    }
+
     bpp = bytestream2_get_le32(gbc); // rgbbitcount
     r   = bytestream2_get_le32(gbc); // rbitmask
     g   = bytestream2_get_le32(gbc); // gbitmask



More information about the libav-commits mailing list