From eb554d124be4c0b440d253bddb06e86665a7c61c Mon Sep 17 00:00:00 2001
From: Cristy <urban-warrior@imagemagick.org>
Date: Thu, 23 Nov 2017 09:05:46 -0500
Subject: [PATCH] ...

---
 coders/wpg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/coders/wpg.c b/coders/wpg.c
index 3680282a7..e288e2617 100644
--- a/coders/wpg.c
+++ b/coders/wpg.c
@@ -1096,8 +1096,6 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
               if ((BitmapHeader2.Width == 0) || (BitmapHeader2.Height == 0))
                 ThrowReaderException(CorruptImageError,"ImproperImageHeader");
               BitmapHeader2.Depth=ReadBlobLSBShort(image);
-              if (BitmapHeader2.Depth > 32)
-                ThrowReaderException(CorruptImageError,"ImproperImageHeader");
               BitmapHeader2.HorzRes=ReadBlobLSBShort(image);
               BitmapHeader2.VertRes=ReadBlobLSBShort(image);
 
@@ -1118,6 +1116,8 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
               bpp=BitmapHeader2.Depth;
 
             UnpackRaster:
+              if (bpp > 32)
+                ThrowReaderException(CorruptImageError,"ImproperImageHeader");
               status=SetImageExtent(image,image->columns,image->rows,exception);
               if (status == MagickFalse)
                 break;
-- 
2.40.0