From 76d045a787b16952e2111c248713e72de2f593da Mon Sep 17 00:00:00 2001 From: cristy Date: Tue, 2 Dec 2014 02:12:04 +0000 Subject: [PATCH] --- coders/psd.c | 4 ++-- coders/sun.c | 4 ++-- coders/xpm.c | 33 +++++++++++++++------------------ 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/coders/psd.c b/coders/psd.c index b8e3cc503..6334bc0ba 100644 --- a/coders/psd.c +++ b/coders/psd.c @@ -803,7 +803,7 @@ static MagickStatusType ReadPSDChannelRaw(Image *image,const size_t channels, " layer data is RAW"); row_size=GetPSDRowSize(image); - pixels=(unsigned char *) AcquireQuantumMemory(row_size,sizeof(*pixels)); + pixels=(unsigned char *) AcquireQuantumMemory(8*row_size,sizeof(*pixels)); if (pixels == (unsigned char *) NULL) ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); @@ -872,7 +872,7 @@ static MagickStatusType ReadPSDChannelRLE(Image *image,const PSDInfo *psd_info, " layer data is RLE compressed"); row_size=GetPSDRowSize(image); - pixels=(unsigned char *) AcquireQuantumMemory(row_size,sizeof(*pixels)); + pixels=(unsigned char *) AcquireQuantumMemory(8*row_size,sizeof(*pixels)); if (pixels == (unsigned char *) NULL) ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); diff --git a/coders/sun.c b/coders/sun.c index 0479a01b6..3a7d515bb 100644 --- a/coders/sun.c +++ b/coders/sun.c @@ -305,9 +305,9 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception) sun_info.maplength=ReadBlobMSBLong(image); if ((sun_info.type != RT_STANDARD) && (sun_info.type != RT_ENCODED) && (sun_info.type != RT_FORMAT_RGB)) - ThrowReaderException(CoderError,"ImproperImageHeader"); + ThrowReaderException(CorruptImageError,"ImproperImageHeader"); if ((sun_info.maptype == RMT_NONE) && (sun_info.maplength != 0)) - ThrowReaderException(CoderError,"ImproperImageHeader"); + ThrowReaderException(CorruptImageError,"ImproperImageHeader"); if ((sun_info.depth == 0) || (sun_info.depth > 32)) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); if ((sun_info.maptype != RMT_NONE) && (sun_info.maptype != RMT_EQUAL_RGB) && diff --git a/coders/xpm.c b/coders/xpm.c index 7318aa2b4..e7e7f1225 100644 --- a/coders/xpm.c +++ b/coders/xpm.c @@ -165,7 +165,7 @@ static size_t CopyXPMColor(char *destination,const char *source,size_t length) static char *NextXPMLine(char *p) { - assert(p != (char*)NULL); + assert(p != (char *)NULL); p=strchr(p,'\n'); if (p != (char *) NULL) p++; @@ -222,24 +222,21 @@ static char *ParseXPMColor(char *color,MagickBooleanType search_start) } return((char *) NULL); } - else + for (p=color+1; *p != '\0'; p++) + { + if (*p == '\n') + break; + if (isspace((int) ((unsigned char) (*(p-1)))) == 0) + continue; + if (isspace((int) ((unsigned char) (*p))) != 0) + continue; + for (i=0; i < NumberTargets; i++) { - for (p=color+1; *p != '\0'; p++) - { - if (*p == '\n') - break; - if (isspace((int) ((unsigned char) (*(p-1)))) == 0) - continue; - if (isspace((int) ((unsigned char) (*p))) != 0) - continue; - for (i=0; i < NumberTargets; i++) - { - if (*p == *targets[i] && *(p+1) == *(targets[i]+1)) - return(p); - } - } - return(p); + if ((*p == *targets[i]) && (*(p+1) == *(targets[i]+1))) + return(p); } + } + return(p); } static Image *ReadXPMImage(const ImageInfo *image_info,ExceptionInfo *exception) @@ -377,7 +374,7 @@ static Image *ReadXPMImage(const ImageInfo *image_info,ExceptionInfo *exception) */ image->depth=1; next=NextXPMLine(xpm_buffer); - for (j=0; (j < (ssize_t) image->colors) && (next != (char*) NULL); j++) + for (j=0; (j < (ssize_t) image->colors) && (next != (char *) NULL); j++) { p=next; next=NextXPMLine(p); -- 2.40.0