From: cristy Date: Sun, 21 Dec 2014 23:32:29 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~1579 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc798fbe0021d7350d6a0da498230cb5b3c95406;p=imagemagick --- diff --git a/MagickCore/colormap-private.h b/MagickCore/colormap-private.h index f54c50a09..1dfce2235 100644 --- a/MagickCore/colormap-private.h +++ b/MagickCore/colormap-private.h @@ -38,6 +38,20 @@ static inline ssize_t ConstrainColormapIndex(Image *image,const ssize_t index, return((ssize_t) index); } +static inline MagickBooleanType IsValidColormapIndex(Image *image, + const ssize_t index,Quantum *target,ExceptionInfo *exception) +{ + if ((index < 0) || (index >= (ssize_t) image->colors)) + { + (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError, + "InvalidColormapIndex","`%s'",image->filename); + *target=(Quantum) 0; + return(MagickFalse); + } + *target=(Quantum) index; + return(MagickTrue); +} + #if defined(__cplusplus) || defined(c_plusplus) } #endif