diff --git a/coders/gray.c b/coders/gray.c
index 9b7535b..110f026 100644
--- a/coders/gray.c
+++ b/coders/gray.c
@@ -196,12 +196,6 @@
{
length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
count=ReadBlob(image,length,pixels);
- if (count != (ssize_t) length)
- {
- ThrowFileException(exception,CorruptImageError,
- "UnexpectedEndOfFile",image->filename);
- break;
- }
}
for (y=0; y < (long) image->extract_info.height; y++)
{
@@ -214,6 +208,12 @@
register PixelPacket
*__restrict q;
+ if (count != (ssize_t) length)
+ {
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
+ break;
+ }
q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
@@ -221,14 +221,6 @@
quantum_type,pixels,exception);
if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
break;
- count=ReadBlob(image,length,pixels);
- if ((count != (ssize_t) length) &&
- (y < (long) (image->extract_info.height-1)))
- {
- ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
- image->filename);
- break;
- }
if (((y-image->extract_info.y) >= 0) &&
((y-image->extract_info.y) < (long) image->rows))
{
@@ -255,6 +247,7 @@
if (status == MagickFalse)
break;
}
+ count=ReadBlob(image,length,pixels);
}
SetQuantumImageType(image,quantum_type);
/*