]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Fri, 18 Apr 2014 01:27:37 +0000 (01:27 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Fri, 18 Apr 2014 01:27:37 +0000 (01:27 +0000)
16 files changed:
MagickCore/blob.c
MagickCore/distribute-cache.c
MagickCore/morphology.c
MagickWand/pixel-wand.c
coders/cals.c
coders/cin.c
coders/dcm.c
coders/dds.c
coders/fits.c
coders/hdr.c
coders/mat.c
coders/pict.c
coders/pwp.c
coders/rla.c
coders/sfw.c
coders/svg.c

index aaa1aba622ebed2d66d4428312ac2cfafea8a29d..baf69b31e97ec02365fe112bb5c7543b551c8deb 100644 (file)
@@ -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);
     }
index 6a072380c50981519bfd31570fd7de66c867eef0..1d42ca5e0137ca8863ae2fbe207ba89aded4b8ff 100644 (file)
@@ -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)
       {
index 6440a4f3d0e86fa5ef43f4d1e7697ce31967ee1b..927a7222528d6b5969b0d44b9ee988f81cd40b30 100644 (file)
@@ -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);
index e88116299a2b642791c910fa901c48bab10aac74..f1fdd45400b5c5fa8232a85bf962f51938b70dfe 100644 (file)
@@ -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);
index 93381a774a51221b05d27f2f2913a201126e1608..c4e7dd5bd044411835dd45d187a2a9c2dba93e48 100644 (file)
@@ -145,7 +145,7 @@ static Image *ReadCALSImage(const ImageInfo *image_info,
 {
   char
     filename[MaxTextExtent],
-    header[129],
+    header[MaxTextExtent],
     message[MaxTextExtent];
 
   FILE
index 27ffc90d28a791d16c48a034c9dcb1fdb9940b1e..ef78c14f082b50e93f4c567aa0a62339b86380f6 100644 (file)
@@ -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",
index 8202eb30ca25c977bec3337f0f335d2aa6e50942..955399a0552940c5e31d6e50782159ed7c98ddd3 100644 (file)
@@ -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);
index 9b8bd7e134e3d20c07dc346d4368881dd6950317..da76a9210720520bfe814bac2bb0f8224099334c 100644 (file)
@@ -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);
index 7ba4d883ed639d2f2132eb3a594cc15cd4d9a02d..5d69de62a93bce6a9fc4d5c0636fa48be9c9f97f 100644 (file)
@@ -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 == '=')
         {
index 61b384abacc9ea46b990471f174e7f5aa6cd6e5c..5597a5d2abe955f8c4d40400c5fbebb31a322c2e 100644 (file)
@@ -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,
index 15039906c0102f342e5f5dd49f86d5f436aaae9e..2affb3a13a89c054d15fc3d423a6a963b2965d23 100644 (file)
@@ -1218,7 +1218,8 @@ static MagickBooleanType WriteMATImage(const ImageInfo *image_info,Image *image,
   (void) memcpy(&local_time,localtime(&current_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);
index 6fef4a6707cca2ff7abaed77c6aaa48770234aa1..ca0c99f602270532bf74d2669e1e72fe4ceedf7f 100644 (file)
@@ -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);
index b97a43cc994a911741e0bdb6c5a90fe5e61863c8..ca2583772b477f71034cd2e1a65de7efdec8d907 100644 (file)
@@ -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);
index 4f6f69046367ee5f8e29e9995f6d90ee719c00ee..0884d06a49ff2bc5ff9985a5e658e8fc9e4407a4 100644 (file)
@@ -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);
index f29c3eea7df27f8572cf5307bd05e2204a82a42a..39d1a6223bc2c70c8bafc4f98327a6d84248ad4a 100644 (file)
@@ -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)
     {
index e4f2df00fce0439c386f09889216172d3afd90f6..e94646142b429ed9e6b36062aa4fbe82416e97cf 100644 (file)
@@ -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;