]> granicus.if.org Git - imagemagick/commitdiff
Make sure image->colormap isn't NULL before we read it.
authorglennrp <glennrp@git.imagemagick.org>
Fri, 25 Feb 2011 04:20:48 +0000 (04:20 +0000)
committerglennrp <glennrp@git.imagemagick.org>
Fri, 25 Feb 2011 04:20:48 +0000 (04:20 +0000)
coders/png.c

index 58355c885fe9a189c05bea3b6460051c21e7d49a..bd49b12042cdf43fe656dce5b94e2a87a65c045a 100644 (file)
@@ -7477,7 +7477,8 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
              if (SyncAuthenticPixels(image,exception) == MagickFalse)
                 break;
 
-             if (image->colors != 0 && image->colors <= 256)
+             if (image_colors != 0 && image_colors <= 256 &&
+                image->colormap != NULL)
                for (i=0; i<image_colors; i++)
                    image->colormap[i].opacity =
                        image->colormap[i].opacity > OpaqueOpacity/2 ? 0 :
@@ -7490,7 +7491,8 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
         * quantization of the pixels and background color to the 3-3-2
         * palette.
         */
-       if (image_colors == 0 || image_colors > 256)
+       if (image_colors != 0 && image_colors <= 256 &&
+           image->colormap != NULL)
          {
            if (logging != MagickFalse)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -7546,7 +7548,8 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
                 break;
            }
 
-         if (image_colors != 0 && image_colors <= 256)
+         if (image_colors != 0 && image_colors <= 256 &&
+           image->colormap != NULL)
            {
              if (logging != MagickFalse)
                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),