]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Fri, 28 Nov 2014 17:21:58 +0000 (17:21 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Fri, 28 Nov 2014 17:21:58 +0000 (17:21 +0000)
coders/xwd.c

index e7534c1b43e6f2d030f17e3885b893a7d75da33e..9df7e4f93b101494d1502258e5a29aa734d90399 100644 (file)
@@ -456,14 +456,17 @@ static Image *ReadXWDImage(const ImageInfo *image_info,ExceptionInfo *exception)
             {
               pixel=XGetPixel(ximage,(int) x,(int) y);
               index=(Quantum) ((pixel >> red_shift) & red_mask);
-              SetPixelRed(image,ScaleShortToQuantum(
-                colors[(ssize_t) index].red),q);
+              if (index < header.ncolors)
+                SetPixelRed(image,ScaleShortToQuantum(
+                  colors[(ssize_t) index].red),q);
               index=(Quantum) ((pixel >> green_shift) & green_mask);
-              SetPixelGreen(image,ScaleShortToQuantum(
-                colors[(ssize_t) index].green),q);
+              if (index < header.ncolors)
+                SetPixelGreen(image,ScaleShortToQuantum(
+                  colors[(ssize_t) index].green),q);
               index=(Quantum) ((pixel >> blue_shift) & blue_mask);
-              SetPixelBlue(image,ScaleShortToQuantum(
-                colors[(ssize_t) index].blue),q);
+              if (index < header.ncolors)
+                SetPixelBlue(image,ScaleShortToQuantum(
+                  colors[(ssize_t) index].blue),q);
               q+=GetPixelChannels(image);
             }
             if (SyncAuthenticPixels(image,exception) == MagickFalse)