% July 1992 %
% %
% %
-% Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
comment=AcquireString(GetImageProperty(image,"comment",exception));
p=comment+strlen(comment);
extent=strlen(comment)+MagickPathExtent;
- for (c='#'; (c != EOF) && (c != (int) '\n'); p++)
+ for (c='#'; (c != EOF) && (c != (int) '\n') && (c != (int) '\r'); p++)
{
if ((size_t) (p-comment+1) >= extent)
{
Evaluate number.
*/
value=0;
- while (isdigit(c) != 0) {
- if (value > (unsigned int) (INT_MAX/10))
- break;
- value*=10;
- if (value > (unsigned int) (INT_MAX-(c-(int) '0')))
- break;
- value+=c-(int) '0';
+ while (isdigit(c) != 0)
+ {
+ if (value <= (unsigned int) (INT_MAX/10))
+ {
+ value*=10;
+ if (value <= (unsigned int) (INT_MAX-(c-(int) '0')))
+ value+=c-(int) '0';
+ }
c=ReadBlobByte(image);
if (c == EOF)
return(0);
}
+ if (c == (int) '#')
+ c=PNMComment(image,exception);
return(value);
}
}
if ((image->columns == 0) || (image->rows == 0))
ThrowReaderException(CorruptImageError,"NegativeOrZeroImageSize");
- if ((max_value == 0) || (max_value > 4294967295))
+ if ((max_value == 0) || (max_value > 4294967295UL))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
for (depth=1; GetQuantumRange(depth) < max_value; depth++) ;
image->depth=depth;
pixels=(unsigned char *) ReadBlobStream(image,extent,
GetQuantumPixels(quantum_info),&count);
- if ((size_t) count != extent)
+ if (count != (ssize_t) extent)
break;
if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&
(image->previous == (Image *) NULL))