]> granicus.if.org Git - imagemagick/blobdiff - coders/pnm.c
(no commit message)
[imagemagick] / coders / pnm.c
index eb2837e2bd1f4925c00e1d80e178f6db0a775dbf..50a8a2dbbf4e82dcc817713481ee0bff3539679a 100644 (file)
@@ -198,23 +198,24 @@ static unsigned int PNMInteger(Image *image,const unsigned int base,
       return(0);
     if (c == (int) '#')
       PNMComment(image,exception);
-  } while (isdigit(c) == MagickFalse);
+  } while ((c == ' ') || (c == '\t') || (c == '\n') || (c == '\r'));
   if (base == 2)
     return((unsigned int) (c-(int) '0'));
   /*
     Evaluate number.
   */
   value=0;
-  do
-  {
+  while (isdigit(c) != 0) {
     if (value > (unsigned int) (INT_MAX/10))
       break;
     value*=10;
-    if (value > (INT_MAX-c))
+    if (value > (INT_MAX-(c-(int) '0')))
       break;
     value+=c-(int) '0';
     c=ReadBlobByte(image);
-  } while (isdigit(c) != 0);
+    if (c == EOF)
+      return(0);
+  }
   return(value);
 }