]> granicus.if.org Git - imagemagick/commitdiff
Moved call to `SetImageExtent` to exit earlier.
authorDirk Lemstra <dirk@git.imagemagick.org>
Tue, 9 Jan 2018 22:42:04 +0000 (23:42 +0100)
committerDirk Lemstra <dirk@git.imagemagick.org>
Tue, 9 Jan 2018 22:42:04 +0000 (23:42 +0100)
Credit to OSS-Fuzz

coders/pcx.c

index b32f558ea7f4cbe9ff5661d1ef0b5a78a4f2de8c..798c301e1b1f6130135a5ba59d504eb83acb363e 100644 (file)
@@ -351,6 +351,12 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     image->resolution.x=(double) pcx_info.horizontal_resolution;
     image->resolution.y=(double) pcx_info.vertical_resolution;
     image->colors=16;
+    if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
+      if (image->scene >= (image_info->scene+image_info->number_scenes-1))
+        break;
+    status=SetImageExtent(image,image->columns,image->rows,exception);
+    if (status == MagickFalse)
+      ThrowPCXException(exception->severity,exception->reason);
     count=ReadBlob(image,3*image->colors,pcx_colormap);
     if (count != (ssize_t) (3*image->colors))
       ThrowPCXException(CorruptImageError,"ImproperImageHeader");
@@ -385,12 +391,6 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     pcx_info.vertical_screensize=ReadBlobLSBShort(image);
     for (i=0; i < 54; i++)
       (void) ReadBlobByte(image);
-    if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
-      if (image->scene >= (image_info->scene+image_info->number_scenes-1))
-        break;
-    status=SetImageExtent(image,image->columns,image->rows,exception);
-    if (status == MagickFalse)
-      ThrowPCXException(exception->severity,exception->reason);
     /*
       Read image data.
     */