From 53d0150877bdc6f25504cd37c9aff0b2ebe2a5d7 Mon Sep 17 00:00:00 2001 From: cristy Date: Tue, 16 Dec 2014 18:59:44 +0000 Subject: [PATCH] --- MagickCore/colormap-private.h | 7 ++++--- coders/palm.c | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/MagickCore/colormap-private.h b/MagickCore/colormap-private.h index a57097ab0..234458328 100644 --- a/MagickCore/colormap-private.h +++ b/MagickCore/colormap-private.h @@ -26,16 +26,17 @@ extern "C" { #endif -static inline ssize_t ConstrainColormapIndex(Image *image,const ssize_t index, +static inline ssize_t ConstrainColormapIndex(Image *image,const size_t index, ExceptionInfo *exception) { - if ((index < 0) || (index >= (ssize_t) image->colors)) + if ((index < 0) || (index >= (ssize_t) image->colors) || + ((ssize_t) index < 0)) { (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError, "InvalidColormapIndex","`%s'",image->filename); return(0); } - return(index); + return((ssize_t) index); } #if defined(__cplusplus) || defined(c_plusplus) diff --git a/coders/palm.c b/coders/palm.c index 97d201c1c..3caf1363d 100644 --- a/coders/palm.c +++ b/coders/palm.c @@ -519,8 +519,10 @@ static Image *ReadPALMImage(const ImageInfo *image_info, } if (flags & PALM_HAS_TRANSPARENCY_FLAG) { + ssize_t index=ConstrainColormapIndex(image,(mask-transparentIndex), + exception); if (bits_per_pixel != 16) - transpix=image->colormap[mask-transparentIndex]; + transpix=image->colormap[index]; (void) TransparentPaintImage(image,&transpix,(Quantum) TransparentAlpha, MagickFalse,exception); } -- 2.40.0