]> granicus.if.org Git - imagemagick/commitdiff
Width/height sanity check
authorCristy <mikayla-grace@urban-warrior.org>
Sat, 11 May 2019 14:44:09 +0000 (10:44 -0400)
committerCristy <mikayla-grace@urban-warrior.org>
Sat, 11 May 2019 14:44:09 +0000 (10:44 -0400)
MagickCore/cache.c
MagickCore/xwindow.c
coders/miff.c

index e3400efbe4ea0b67d7d8eea04971094c5205ee97..96963ad44c09119685e281aef08f34fdba0618ae 100644 (file)
@@ -5018,6 +5018,12 @@ static Quantum *SetPixelCacheNexusPixels(
   assert(cache_info->signature == MagickCoreSignature);
   if (cache_info->type == UndefinedCache)
     return((Quantum *) NULL);
+  if ((width == 0) || (height == 0))
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
+        "NoPixelsDefinedInCache","`%s'",cache_info->filename);
+      return((Quantum *) NULL);
+    }
   (void) memset(&nexus_info->region,0,sizeof(nexus_info->region));
   assert(nexus_info->signature == MagickCoreSignature);
   if (((cache_info->type == MemoryCache) || (cache_info->type == MapCache)) &&
index 3cbebc39d7c002beacc34965b23bb57a34d2f401..52d8839a574544e75ef646206e62331dc33b3ecd 100644 (file)
@@ -6706,8 +6706,8 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
           /*
             Convert to 8 bit color-mapped X canvas.
           */
-          if (resource_info->color_recovery &&
-              resource_info->quantize_info->dither_method != NoDitherMethod)
+          if ((resource_info->color_recovery != MagickFalse) &&
+              (resource_info->quantize_info->dither_method != NoDitherMethod))
             {
               XDitherImage(canvas,ximage,exception);
               break;
@@ -6870,8 +6870,8 @@ static void XMakeImageMSBFirst(const XResourceInfo *resource_info,
           /*
             Convert to 8 bit continuous-tone X canvas.
           */
-          if (resource_info->color_recovery &&
-              resource_info->quantize_info->dither_method != NoDitherMethod)
+          if ((resource_info->color_recovery != MagickFalse) &&
+              (resource_info->quantize_info->dither_method != NoDitherMethod))
             {
               XDitherImage(canvas,ximage,exception);
               break;
index 0de54fb94d80e9b8888c3c95321fbacfd6cb323c..56df00194d54eed61949020efc70c8f6217ce193 100644 (file)
@@ -232,7 +232,7 @@ static void PushRunlengthPacket(Image *image,const unsigned char *pixels,
         case 16:
         {
           pixel->index=(MagickRealType) ConstrainColormapIndex(image,(ssize_t)
-            ((*p << 8) | *(p+1)),exception);
+            (((size_t) *p << 8) | (size_t) *(p+1)),exception);
           p+=2;
           break;
         }
@@ -291,7 +291,7 @@ static void PushRunlengthPacket(Image *image,const unsigned char *pixels,
           (void) ThrowMagickException(exception,GetMagickModule(),
             CorruptImageError,"ImageDepthNotSupported","`%s'",image->filename);
       }
-      *length=(size_t) (*p++)+1;
+      *length=((size_t) *p++)+1;
       return;
     }
   switch (image->depth)