]> granicus.if.org Git - imagemagick/blobdiff - coders/pnm.c
...
[imagemagick] / coders / pnm.c
index 76fce2f5359c1804253cc8ba8eff297a179b7a6a..21c0e895d34fdada2756129ac577c07193294167 100644 (file)
@@ -17,7 +17,7 @@
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2017 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  %
@@ -443,7 +443,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             x;
 
           register Quantum
-            *restrict q;
+            *magick_restrict q;
 
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (Quantum *) NULL)
@@ -452,6 +452,8 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           {
             SetPixelGray(image,PNMInteger(image,2,exception) == 0 ?
               QuantumRange : 0,q);
+            if (EOFBlob(image) != MagickFalse)
+              break;
             q+=GetPixelChannels(image);
           }
           if (SyncAuthenticPixels(image,exception) == MagickFalse)
@@ -463,6 +465,8 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
               if (status == MagickFalse)
                 break;
             }
+          if (EOFBlob(image) != MagickFalse)
+            break;
         }
         image->type=BilevelType;
         break;
@@ -482,7 +486,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             x;
 
           register Quantum
-            *restrict q;
+            *magick_restrict q;
 
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (Quantum *) NULL)
@@ -491,6 +495,8 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           {
             intensity=ScaleAnyToQuantum(PNMInteger(image,10,exception),
               max_value);
+            if (EOFBlob(image) != MagickFalse)
+              break;
             SetPixelGray(image,intensity,q);
             q+=GetPixelChannels(image);
           }
@@ -503,6 +509,8 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
               if (status == MagickFalse)
                 break;
             }
+          if (EOFBlob(image) != MagickFalse)
+            break;
         }
         image->type=GrayscaleType;
         break;
@@ -518,7 +526,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             x;
 
           register Quantum
-            *restrict q;
+            *magick_restrict q;
 
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (Quantum *) NULL)
@@ -529,6 +537,8 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
               pixel;
 
             pixel=ScaleAnyToQuantum(PNMInteger(image,10,exception),max_value);
+            if (EOFBlob(image) != MagickFalse)
+              break;
             SetPixelRed(image,pixel,q);
             pixel=ScaleAnyToQuantum(PNMInteger(image,10,exception),max_value);
             SetPixelGreen(image,pixel,q);
@@ -545,6 +555,8 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
               if (status == MagickFalse)
                 break;
             }
+          if (EOFBlob(image) != MagickFalse)
+            break;
         }
         break;
       }
@@ -571,7 +583,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             sync;
 
           register Quantum
-            *restrict q;
+            *magick_restrict q;
 
           ssize_t
             count,
@@ -644,13 +656,13 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             sync;
 
           register const unsigned char
-            *restrict p;
+            *magick_restrict p;
 
           register ssize_t
             x;
 
           register Quantum
-            *restrict q;
+            *magick_restrict q;
 
           ssize_t
             count,
@@ -761,13 +773,13 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             sync;
 
           register const unsigned char
-            *restrict p;
+            *magick_restrict p;
 
           register ssize_t
             x;
 
           register Quantum
-            *restrict q;
+            *magick_restrict q;
 
           ssize_t
             count,
@@ -961,13 +973,13 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             sync;
 
           register const unsigned char
-            *restrict p;
+            *magick_restrict p;
 
           register ssize_t
             x;
 
           register Quantum
-            *restrict q;
+            *magick_restrict q;
 
           ssize_t
             count,
@@ -1283,7 +1295,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             sync;
 
           register Quantum
-            *restrict q;
+            *magick_restrict q;
 
           ssize_t
             count,
@@ -1723,7 +1735,7 @@ static MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image,
         for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const Quantum
-            *restrict p;
+            *magick_restrict p;
 
           register ssize_t
             x;
@@ -1781,7 +1793,7 @@ static MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image,
         for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const Quantum
-            *restrict p;
+            *magick_restrict p;
 
           register ssize_t
             x;
@@ -1851,7 +1863,7 @@ static MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image,
         for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const Quantum
-            *restrict p;
+            *magick_restrict p;
 
           register ssize_t
             x;
@@ -1922,7 +1934,7 @@ static MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image,
         for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const Quantum
-            *restrict p;
+            *magick_restrict p;
 
           p=GetVirtualPixels(image,0,y,image->columns,1,exception);
           if (p == (const Quantum *) NULL)
@@ -1963,7 +1975,7 @@ static MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image,
         for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const Quantum
-            *restrict p;
+            *magick_restrict p;
 
           register ssize_t
             x;
@@ -2079,7 +2091,7 @@ static MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image,
         for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const Quantum
-            *restrict p;
+            *magick_restrict p;
 
           register ssize_t
             x;
@@ -2173,7 +2185,7 @@ static MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image,
         for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const Quantum
-            *restrict p;
+            *magick_restrict p;
 
           register ssize_t
             x;
@@ -2414,7 +2426,6 @@ static MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image,
         quantum_info=AcquireQuantumInfo(image_info,image);
         if (quantum_info == (QuantumInfo *) NULL)
           ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
-        (void) SetQuantumEndian(image,quantum_info,MSBEndian);
         status=SetQuantumFormat(image,quantum_info,FloatingPointQuantumFormat);
         if (status == MagickFalse)
           ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
@@ -2422,7 +2433,7 @@ static MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image,
         for (y=(ssize_t) image->rows-1; y >= 0; y--)
         {
           register const Quantum
-            *restrict p;
+            *magick_restrict p;
 
           p=GetVirtualPixels(image,0,y,image->columns,1,exception);
           if (p == (const Quantum *) NULL)