]> granicus.if.org Git - imagemagick/commitdiff
https://github.com/ImageMagick/ImageMagick/issues/449
authorCristy <urban-warrior@imagemagick.org>
Wed, 26 Apr 2017 21:16:56 +0000 (17:16 -0400)
committerCristy <urban-warrior@imagemagick.org>
Wed, 26 Apr 2017 21:16:56 +0000 (17:16 -0400)
coders/sun.c

index c3d87dc4584447a86ab8a8422f333a70caf22e07..c10562f67ecdbad758301e5540f8dc6c0592ef14 100644 (file)
@@ -363,19 +363,28 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
         count=ReadBlob(image,image->colors,sun_colormap);
         if (count != (ssize_t) image->colors)
-          ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile");
+          {
+            sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap);
+            ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile");
+          }
         for (i=0; i < (ssize_t) image->colors; i++)
           image->colormap[i].red=(MagickRealType) ScaleCharToQuantum(
             sun_colormap[i]);
         count=ReadBlob(image,image->colors,sun_colormap);
         if (count != (ssize_t) image->colors)
-          ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile");
+          {
+            sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap);
+            ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile");
+          }
         for (i=0; i < (ssize_t) image->colors; i++)
           image->colormap[i].green=(MagickRealType) ScaleCharToQuantum(
             sun_colormap[i]);
         count=ReadBlob(image,image->colors,sun_colormap);
         if (count != (ssize_t) image->colors)
-          ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile");
+          {
+            sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap);
+            ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile");
+          }
         for (i=0; i < (ssize_t) image->colors; i++)
           image->colormap[i].blue=(MagickRealType) ScaleCharToQuantum(
             sun_colormap[i]);
@@ -395,9 +404,9 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
         if (sun_colormap == (unsigned char *) NULL)
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
         count=ReadBlob(image,sun_info.maplength,sun_colormap);
+        sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap);
         if (count != (ssize_t) sun_info.maplength)
           ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile");
-        sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap);
         break;
       }
       default: