]> granicus.if.org Git - imagemagick/commitdiff
Renamed IsValidColormapIndex to ValidateColormapValue and changed the return type...
authordirk <dirk@git.imagemagick.org>
Wed, 6 Apr 2016 21:45:46 +0000 (23:45 +0200)
committerdirk <dirk@git.imagemagick.org>
Thu, 7 Apr 2016 20:42:36 +0000 (22:42 +0200)
MagickCore/colormap-private.h
coders/bmp.c
coders/rle.c

index 28eeecb8636363a05c4cd1f7d69c9069bb0c715e..756e7f9af3981ef0164457d66f7a1b93adafdffb 100644 (file)
@@ -38,7 +38,7 @@ static inline ssize_t ConstrainColormapIndex(Image *image,const ssize_t index,
   return((ssize_t) index);
 }
 
-static inline MagickBooleanType IsValidColormapIndex(Image *image,
+static inline void ValidateColormapValue(Image *image,
   const ssize_t index,Quantum *target,ExceptionInfo *exception)
 { 
   if ((index < 0) || (index >= (ssize_t) image->colors))
@@ -46,10 +46,9 @@ static inline MagickBooleanType IsValidColormapIndex(Image *image,
       (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
         "InvalidColormapIndex","`%s'",image->filename);
       *target=(Quantum) 0;
-      return(MagickFalse);
     }
-  *target=(Quantum) index;
-  return(MagickTrue);
+  else
+    *target=(Quantum) index;
 }
 
 #if defined(__cplusplus) || defined(c_plusplus)
index a8e9181c6266a6733d9a2ff78b758110bf6db5f8..f9cc26c5a610f27bddfb85639d506c3965e30629 100644 (file)
@@ -1099,18 +1099,17 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
             break;
           for (x=0; x < ((ssize_t) image->columns-1); x+=2)
           {
-            (void) IsValidColormapIndex(image,(*p >> 4) & 0x0f,&index,
-              exception);
+            ValidateColormapValue(image,(*p >> 4) & 0x0f,&index,exception);
             SetPixelIndex(image,index,q);
             q+=GetPixelChannels(image);
-            (void) IsValidColormapIndex(image,*p & 0x0f,&index,exception);
+            ValidateColormapValue(image,*p & 0x0f,&index,exception);
             SetPixelIndex(image,index,q);
             q+=GetPixelChannels(image);
             p++;
           }
           if ((image->columns % 2) != 0)
             {
-              IsValidColormapIndex(image,(*p >> 4) & 0xf,&index,exception);
+              ValidateColormapValue(image,(*p >> 4) & 0xf,&index,exception);
               SetPixelIndex(image,index,q);
               q+=GetPixelChannels(image);
               p++;
@@ -1147,7 +1146,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
             break;
           for (x=(ssize_t) image->columns; x != 0; --x)
           {
-            (void) IsValidColormapIndex(image,*p++,&index,exception);
+            ValidateColormapValue(image,*p++,&index,exception);
             SetPixelIndex(image,index,q);
             q+=GetPixelChannels(image);
           }
index 2af1bb3a7b172d300c47ee87a61e2f1e4cb12098..2a8b69457933fb906e70893a59c82435881541cd 100644 (file)
@@ -458,9 +458,7 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception)
         if (number_colormaps == 1)
           for (i=0; i < (ssize_t) number_pixels; i++)
           {
-            if (IsValidColormapIndex(image,*p & mask,&index,exception) ==
-                MagickFalse)
-              break;
+            ValidateColormapValue(image,*p & mask,&index,exception);
             *p=colormap[(ssize_t) index];
             p++;
           }
@@ -469,9 +467,8 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception)
             for (i=0; i < (ssize_t) number_pixels; i++)
               for (x=0; x < (ssize_t) number_planes; x++)
               {
-                if (IsValidColormapIndex(image,(size_t) (x*map_length+
-                    (*p & mask)),&index,exception) == MagickFalse)
-                  break;
+                ValidateColormapValue(image,(size_t) (x*map_length+
+                    (*p & mask)),&index,exception);
                 *p=colormap[(ssize_t) index];
                 p++;
               }
@@ -591,19 +588,13 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 break;
               for (x=0; x < (ssize_t) image->columns; x++)
               {
-                if (IsValidColormapIndex(image,(ssize_t) *p++,&index,
-                    exception) == MagickFalse)
-                  break;
+                ValidateColormapValue(image,(ssize_t) *p++,&index,exception);
                 SetPixelRed(image,ClampToQuantum(image->colormap[(ssize_t)
                   index].red),q);
-                if (IsValidColormapIndex(image,(ssize_t) *p++,&index,
-                    exception) == MagickFalse)
-                  break;
+                ValidateColormapValue(image,(ssize_t) *p++,&index,exception);
                 SetPixelGreen(image,ClampToQuantum(image->colormap[(ssize_t)
                   index].green),q);
-                if (IsValidColormapIndex(image,(ssize_t) *p++,&index,
-                    exception) == MagickFalse)
-                  break;
+                ValidateColormapValue(image,(ssize_t) *p++,&index,exception);
                 SetPixelBlue(image,ClampToQuantum(image->colormap[(ssize_t)
                   index].blue),q);
                 SetPixelAlpha(image,ScaleCharToQuantum(*p++),q);