Skip to content

Commit 0c5b1e4

Browse files
author
Dirk Lemstra
committed
Added check to prevent image being 0x0 (reported in #489).
1 parent e8fc3f1 commit 0c5b1e4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Diff for: coders/dds.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -1677,16 +1677,15 @@ static Image *ReadDDSImage(const ImageInfo *image_info,ExceptionInfo *exception)
16771677
/*
16781678
Initialize image structure.
16791679
*/
1680-
if (ReadDDSInfo(image, &dds_info) != MagickTrue) {
1680+
if (ReadDDSInfo(image, &dds_info) != MagickTrue)
16811681
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
1682-
}
1683-
1682+
16841683
if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP)
16851684
cubemap = MagickTrue;
1686-
1685+
16871686
if (dds_info.ddscaps2 & DDSCAPS2_VOLUME && dds_info.depth > 0)
16881687
volume = MagickTrue;
1689-
1688+
16901689
(void) SeekBlob(image, 128, SEEK_SET);
16911690

16921691
/*
@@ -1775,7 +1774,10 @@ static Image *ReadDDSImage(const ImageInfo *image_info,ExceptionInfo *exception)
17751774

17761775
if (volume)
17771776
num_images = dds_info.depth;
1778-
1777+
1778+
if (num_images < 1)
1779+
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
1780+
17791781
for (n = 0; n < num_images; n++)
17801782
{
17811783
if (n != 0)

0 commit comments

Comments
 (0)