File ImageMagick-CVE-2019-19948.patch of Package ImageMagick.29976

diff --git a/coders/sgi.c b/coders/sgi.c
index 236bf4cb91..415598122c 100644
--- a/coders/sgi.c
+++ b/coders/sgi.c
@@ -953,8 +953,6 @@ static MagickBooleanType WriteSGIImage(const ImageInfo *image_info,Image *image,
   assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
-  if ((image->columns > 65535UL) || (image->rows > 65535UL))
-    ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit");
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickCoreSignature);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
@@ -967,6 +965,8 @@ static MagickBooleanType WriteSGIImage(const ImageInfo *image_info,Image *image,
     /*
       Initialize SGI raster file header.
     */
+    if ((image->columns > 65535UL) || (image->rows > 65535UL))
+      ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit");
     (void) TransformImageColorspace(image,sRGBColorspace,exception);
     (void) memset(&iris_info,0,sizeof(iris_info));
     iris_info.magic=0x01DA;

openSUSE Build Service is sponsored by