[prev in list] [next in list] [prev in thread] [next in thread] 

List:       graphicsmagick-commit
Subject:    [GM-commit] GraphicsMagick: TIM: Fix memory leak of TIM pixel buffer in erro...
From:       GraphicsMagick Commits <graphicsmagick-commit () lists ! sourceforge ! net>
Date:       2017-09-30 19:45:39
Message-ID: mailman.1875.1506800747.12770.graphicsmagick-commit () lists ! sourceforge ! net
[Download RAW message or body]

changeset 53a000dfa335 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=53a000dfa335
summary: TIM: Fix memory leak of TIM pixel buffer in error path.

diffstat:

 coders/tim.c |  19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diffs (49 lines):

diff -r 59b266bdfcf3 -r 53a000dfa335 coders/tim.c
--- a/coders/tim.c	Sat Sep 30 14:25:25 2017 -0500
+++ b/coders/tim.c	Sat Sep 30 14:45:37 2017 -0500
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -114,7 +114,6 @@
     *p;
 
   unsigned char
-    *tim_data,
     *tim_pixels;
 
   unsigned short
@@ -225,11 +224,14 @@
     if (CheckImagePixelLimits(image, exception) != MagickPass)
       ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
 
-    tim_data=MagickAllocateMemory(unsigned char *,image_size);
-    if (tim_data == (unsigned char *) NULL)
+    tim_pixels=MagickAllocateMemory(unsigned char *,image_size);
+    if (tim_pixels == (unsigned char *) NULL)
       ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-    (void) ReadBlob(image,image_size,(char *) tim_data);
-    tim_pixels=tim_data;
+    if (ReadBlob(image,image_size,(char *) tim_pixels) != image_size)
+      {
+        MagickFreeMemory(tim_pixels);
+        ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+      }
 
     /*
       Convert TIM raster image to pixel packets.
@@ -368,7 +370,10 @@
         break;
       }
       default:
-        ThrowReaderException(CorruptImageError,ImproperImageHeader,image)
+        {
+          MagickFreeMemory(tim_pixels);
+          ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+        }
     }
     if (image->storage_class == PseudoClass)
       (void) SyncImage(image);

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Graphicsmagick-commit mailing list
Graphicsmagick-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-commit
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic