From 0c5b1e430a83ef793a7334bbbee408cf3c628699 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Mon, 15 May 2017 21:10:09 +0200 Subject: [PATCH] Added check to prevent image being 0x0 (reported in #489). --- coders/dds.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/coders/dds.c b/coders/dds.c index eb9641d05..f1b1d8c71 100644 --- a/coders/dds.c +++ b/coders/dds.c @@ -1677,16 +1677,15 @@ static Image *ReadDDSImage(const ImageInfo *image_info,ExceptionInfo *exception) /* Initialize image structure. */ - if (ReadDDSInfo(image, &dds_info) != MagickTrue) { + if (ReadDDSInfo(image, &dds_info) != MagickTrue) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); - } - + if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP) cubemap = MagickTrue; - + if (dds_info.ddscaps2 & DDSCAPS2_VOLUME && dds_info.depth > 0) volume = MagickTrue; - + (void) SeekBlob(image, 128, SEEK_SET); /* @@ -1775,7 +1774,10 @@ static Image *ReadDDSImage(const ImageInfo *image_info,ExceptionInfo *exception) if (volume) num_images = dds_info.depth; - + + if (num_images < 1) + ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + for (n = 0; n < num_images; n++) { if (n != 0) -- 2.40.0