MPC: Fix memory leak while writing Magick Persistent Cache format.
authorBob Friesenhahn <bfriesen@GraphicsMagick.org>
Sat, 22 Jul 2017 17:56:27 -0500
changeset 15094 db732abd9318
parent 15093 29550606d8b9
child 15095 f3ffc5541257
MPC: Fix memory leak while writing Magick Persistent Cache format.
ChangeLog
magick/pixel_cache.c
www/Changelog.html
--- a/ChangeLog	Sat Jul 22 16:29:35 2017 -0500
+++ b/ChangeLog	Sat Jul 22 17:56:27 2017 -0500
@@ -1,5 +1,9 @@
 2017-07-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
+	* magick/pixel_cache.c (PersistCache): Fix memory leak while
+	writing a MPC file.  Problem was reported by LCatro via email on
+	July 18.
+
 	* coders/map.c (WriteMAPImage): Fix null pointer dereference or
 	segmentation violation in the MAP writer if the input image is not
 	already colormapped.  Problem was reported by LCatro via email on
--- a/magick/pixel_cache.c	Sat Jul 22 16:29:35 2017 -0500
+++ b/magick/pixel_cache.c	Sat Jul 22 17:56:27 2017 -0500
@@ -3458,7 +3458,10 @@
   cache_info->type=DiskCache;
   cache_info->offset=(*offset);
   if (!OpenCache(clone_image,IOMode,exception))
-    return(MagickFail);
+    {
+      DestroyImage(clone_image);
+      return(MagickFail);
+    }
   y=0;
   {
     ViewInfo
@@ -3495,11 +3498,13 @@
     CloseCacheView(image_view);
     CloseCacheView(clone_view);
   }
-  cache_info=(CacheInfo*) ReferenceCache(cache_info);
+  if (y < (long) image->rows)
+    {
+      DestroyImage(clone_image);
+      return(MagickFail);
+    }
+  *offset+=cache_info->length+pagesize-(cache_info->length % pagesize);
   DestroyImage(clone_image);
-  if (y < (long) image->rows)
-    return(MagickFail);
-  *offset+=cache_info->length+pagesize-(cache_info->length % pagesize);
   (void) LogMagickEvent(CacheEvent,GetMagickModule(),"Clone persistent cache");
   return(MagickPass);
 }
--- a/www/Changelog.html	Sat Jul 22 16:29:35 2017 -0500
+++ b/www/Changelog.html	Sat Jul 22 17:56:27 2017 -0500
@@ -38,6 +38,9 @@
 <p>2017-07-22  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
+<li>magick/pixel_cache.c (PersistCache): Fix memory leak while
+writing a MPC file.  Problem was reported by LCatro via email on
+July 18.</li>
 <li>coders/map.c (WriteMAPImage): Fix null pointer dereference or
 segmentation violation in the MAP writer if the input image is not
 already colormapped.  Problem was reported by LCatro via email on