From 3d02a8f06c022ecbe2db6a2ba9bdbd25aed58f8e Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 11 May 2019 10:44:09 -0400 Subject: [PATCH] Width/height sanity check --- MagickCore/cache.c | 6 ++++++ MagickCore/xwindow.c | 8 ++++---- coders/miff.c | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/MagickCore/cache.c b/MagickCore/cache.c index e3400efbe..96963ad44 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -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)) && diff --git a/MagickCore/xwindow.c b/MagickCore/xwindow.c index 3cbebc39d..52d8839a5 100644 --- a/MagickCore/xwindow.c +++ b/MagickCore/xwindow.c @@ -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; diff --git a/coders/miff.c b/coders/miff.c index 0de54fb94..56df00194 100644 --- a/coders/miff.c +++ b/coders/miff.c @@ -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) -- 2.40.0