From: cristy Date: Fri, 18 Apr 2014 01:27:37 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~2450 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=100a056069d5718f995e95a77950dcae6f412ff4;p=imagemagick --- diff --git a/MagickCore/blob.c b/MagickCore/blob.c index aaa1aba62..baf69b31e 100644 --- a/MagickCore/blob.c +++ b/MagickCore/blob.c @@ -690,6 +690,7 @@ MagickExport unsigned char *DetachBlob(BlobInfo *blob_info) if (blob_info->mapped != MagickFalse) { (void) UnmapBlob(blob_info->data,blob_info->length); + blob_info->data=(unsigned char *) NULL; RelinquishMagickResource(MapResource,blob_info->length); } blob_info->mapped=MagickFalse; @@ -1162,6 +1163,7 @@ MagickExport MagickBooleanType FileToImage(Image *image,const char *filename, blob=(unsigned char *) AcquireQuantumMemory(quantum,sizeof(*blob)); if (blob == (unsigned char *) NULL) { + file=close(file); ThrowFileException(exception,ResourceLimitError,"MemoryAllocationFailed", filename); return(MagickFalse); @@ -1700,6 +1702,8 @@ MagickExport MagickBooleanType ImageToFile(Image *image,char *filename, buffer=(unsigned char *) RelinquishMagickMemory(buffer); if ((file == -1) || (i < length)) { + if (file == -1) + file=close(file); ThrowFileException(exception,BlobError,"UnableToWriteBlob",filename); return(MagickFalse); } diff --git a/MagickCore/distribute-cache.c b/MagickCore/distribute-cache.c index 6a072380c..1d42ca5e0 100644 --- a/MagickCore/distribute-cache.c +++ b/MagickCore/distribute-cache.c @@ -207,6 +207,7 @@ static int ConnectPixelCacheServer(const char *hostname,const int port, result->ai_protocol); if (client_socket == -1) { + (void) close(client_socket); (void) ThrowMagickException(exception,GetMagickModule(),CacheError, "DistributedPixelCache","'%s'",hostname); return(-1); @@ -909,7 +910,10 @@ MagickExport void DistributePixelCacheServer(const int port, status=setsockopt(server_socket,SOL_SOCKET,SO_REUSEADDR,&one,(socklen_t) sizeof(one)); if (status == -1) - continue; + { + (void) close(status); + continue; + } status=bind(server_socket,p->ai_addr,p->ai_addrlen); if (status == -1) { diff --git a/MagickCore/morphology.c b/MagickCore/morphology.c index 6440a4f3d..927a72225 100644 --- a/MagickCore/morphology.c +++ b/MagickCore/morphology.c @@ -3669,7 +3669,7 @@ MagickPrivate Image *MorphologyApply(const Image *image, changed; /* number pixels changed by last primitive operation */ char - v_info[80]; + v_info[MaxTextExtent]; assert(image != (Image *) NULL); assert(image->signature == MagickSignature); diff --git a/MagickWand/pixel-wand.c b/MagickWand/pixel-wand.c index e88116299..f1fdd4540 100644 --- a/MagickWand/pixel-wand.c +++ b/MagickWand/pixel-wand.c @@ -741,7 +741,7 @@ WandExport char *PixelGetColorAsString(const PixelWand *wand) WandExport char *PixelGetColorAsNormalizedString(const PixelWand *wand) { char - color[MaxTextExtent]; + color[2*MaxTextExtent]; assert(wand != (const PixelWand *) NULL); assert(wand->signature == WandSignature); diff --git a/coders/cals.c b/coders/cals.c index 93381a774..c4e7dd5bd 100644 --- a/coders/cals.c +++ b/coders/cals.c @@ -145,7 +145,7 @@ static Image *ReadCALSImage(const ImageInfo *image_info, { char filename[MaxTextExtent], - header[129], + header[MaxTextExtent], message[MaxTextExtent]; FILE diff --git a/coders/cin.c b/coders/cin.c index 27ffc90d2..ef78c14f0 100644 --- a/coders/cin.c +++ b/coders/cin.c @@ -605,6 +605,8 @@ static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception) cin.origination.model); (void) SetImageProperty(image,"dpx:origination.model",cin.origination.model, exception); + (void) ResetMagickMemory(cin.origination.serial,0, + sizeof(cin.origination.serial)); offset+=ReadBlob(image,sizeof(cin.origination.serial),(unsigned char *) cin.origination.serial); (void) SetImageProperty(image,"dpx:origination.serial", diff --git a/coders/dcm.c b/coders/dcm.c index 8202eb30c..955399a05 100644 --- a/coders/dcm.c +++ b/coders/dcm.c @@ -3566,7 +3566,10 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception) if (tag == 0xFFFEE0DD) break; /* sequence delimiter tag */ if (tag != 0xFFFEE000) - ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + { + (void) fclose(file); + ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + } for ( ; length != 0; length--) { c=ReadBlobByte(image); diff --git a/coders/dds.c b/coders/dds.c index 9b8bd7e13..da76a9210 100644 --- a/coders/dds.c +++ b/coders/dds.c @@ -1120,6 +1120,11 @@ static void CompressClusterFit(const size_t count, gridrcp.z = 1.0f/31.0f; gridrcp.w = 0.0f; + xSumwSum.x = 0.0f; + xSumwSum.y = 0.0f; + xSumwSum.z = 0.0f; + xSumwSum.w = 0.0f; + ConstructOrdering(count,points,principle,pointsWeights,&xSumwSum,order,0); for (iterationIndex = 0;;) @@ -2636,6 +2641,9 @@ static MagickBooleanType WriteDDSImage(const ImageInfo *image_info, static void WriteDDSInfo(Image *image, const size_t pixelFormat, const size_t compression, const size_t mipmaps) { + char + software[MaxTextExtent]; + register ssize_t i; @@ -2673,7 +2681,9 @@ static void WriteDDSInfo(Image *image, const size_t pixelFormat, (void) WriteBlobLSBLong(image,0x00); (void) WriteBlobLSBLong(image,(unsigned int) mipmaps+1); - (void) WriteBlob(image,44,(unsigned char *) "IMAGEMAGICK"); + (void) ResetMagickMemory(software,0,sizeof(software)); + (void) strcpy(software,"IMAGEMAGICK"); + (void) WriteBlob(image,44,(unsigned char *) software); (void) WriteBlobLSBLong(image,32); (void) WriteBlobLSBLong(image,format); diff --git a/coders/fits.c b/coders/fits.c index 7ba4d883e..5d69de62a 100644 --- a/coders/fits.c +++ b/coders/fits.c @@ -333,10 +333,10 @@ static Image *ReadFITSImage(const ImageInfo *image_info, keyword[i]=tolower((int) ((unsigned char) keyword[i])); } keyword[i]='\0'; + (void) ResetMagickMemory(value,0,sizeof(value)); count=ReadBlob(image,72,(unsigned char *) value); if (count != 72) break; - value[72]='\0'; p=value; if (*p == '=') { diff --git a/coders/hdr.c b/coders/hdr.c index 61b384aba..5597a5d2a 100644 --- a/coders/hdr.c +++ b/coders/hdr.c @@ -797,8 +797,8 @@ static MagickBooleanType WriteHDRImage(const ImageInfo *image_info,Image *image, } else { - count=WriteBlob(image,4*image->columns*sizeof(*pixel),pixel); - if (count != (ssize_t) (4*image->columns*sizeof(*pixel))) + count=WriteBlob(image,4*image->columns*sizeof(*pixels),pixels); + if (count != (ssize_t) (4*image->columns*sizeof(*pixels))) break; } status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, diff --git a/coders/mat.c b/coders/mat.c index 15039906c..2affb3a13 100644 --- a/coders/mat.c +++ b/coders/mat.c @@ -1218,7 +1218,8 @@ static MagickBooleanType WriteMATImage(const ImageInfo *image_info,Image *image, (void) memcpy(&local_time,localtime(¤t_time),sizeof(local_time)); #endif (void) memset(MATLAB_HDR,' ',MagickMin(sizeof(MATLAB_HDR),124)); - FormatLocaleString(MATLAB_HDR,MaxTextExtent,"MATLAB 5.0 MAT-file, Platform: %s, Created on: %s %s %2d %2d:%2d:%2d %d", + FormatLocaleString(MATLAB_HDR,sizeof(MATLAB_HDR), + "MATLAB 5.0 MAT-file, Platform: %s, Created on: %s %s %2d %2d:%2d:%2d %d", OsDesc,DayOfWTab[local_time.tm_wday],MonthsTab[local_time.tm_mon], local_time.tm_mday,local_time.tm_hour,local_time.tm_min, local_time.tm_sec,local_time.tm_year+1900); diff --git a/coders/pict.c b/coders/pict.c index 6fef4a670..ca0c99f60 100644 --- a/coders/pict.c +++ b/coders/pict.c @@ -1391,6 +1391,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info, (void) fputc(c,file); } (void) fclose(file); + (void) close(unique_file); tile_image=ReadImage(read_info,exception); (void) RelinquishUniqueFileResource(read_info->filename); read_info=DestroyImageInfo(read_info); diff --git a/coders/pwp.c b/coders/pwp.c index b97a43cc9..ca2583772 100644 --- a/coders/pwp.c +++ b/coders/pwp.c @@ -239,6 +239,7 @@ static Image *ReadPWPImage(const ImageInfo *image_info,ExceptionInfo *exception) if (status == MagickFalse) break; } + (void) close(unique_file); (void) RelinquishUniqueFileResource(read_info->filename); read_info=DestroyImageInfo(read_info); (void) CloseBlob(pwp_image); diff --git a/coders/rla.c b/coders/rla.c index 4f6f69046..0884d06a4 100644 --- a/coders/rla.c +++ b/coders/rla.c @@ -228,6 +228,7 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception) count=ReadBlob(image,24,(unsigned char *) rla_info.white_point); rla_info.job_number=(int) ReadBlobMSBLong(image); count=ReadBlob(image,128,(unsigned char *) rla_info.name); + (void) ResetMagickMemory(value,0,sizeof(rla_info.description)); count=ReadBlob(image,128,(unsigned char *) rla_info.description); count=ReadBlob(image,64,(unsigned char *) rla_info.program); count=ReadBlob(image,32,(unsigned char *) rla_info.machine); diff --git a/coders/sfw.c b/coders/sfw.c index f29c3eea7..39d1a6223 100644 --- a/coders/sfw.c +++ b/coders/sfw.c @@ -326,6 +326,7 @@ static Image *ReadSFWImage(const ImageInfo *image_info,ExceptionInfo *exception) extent=fwrite(offset+1,(size_t) (data-offset),1,file); status=ferror(file) == -1 ? MagickFalse : MagickTrue; (void) fclose(file); + (void) close(unique_file); buffer=(unsigned char *) RelinquishMagickMemory(buffer); if (status == MagickFalse) { diff --git a/coders/svg.c b/coders/svg.c index e4f2df00f..e94646142 100644 --- a/coders/svg.c +++ b/coders/svg.c @@ -3078,7 +3078,10 @@ static Image *ReadSVGImage(const ImageInfo *image_info,ExceptionInfo *exception) return((Image *) NULL); svg_info=AcquireSVGInfo(); if (svg_info == (SVGInfo *) NULL) - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); + { + (void) fclose(file); + ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); + } svg_info->file=file; svg_info->exception=exception; svg_info->image=image;