[gs-cvs] rev 7759 - trunk/gs/src

ray at ghostscript.com ray at ghostscript.com
Sun Mar 4 08:41:00 PST 2007


Author: ray
Date: 2007-03-04 08:41:00 -0800 (Sun, 04 Mar 2007)
New Revision: 7759

Modified:
   trunk/gs/src/gdevprn.c
Log:
Free up any previous line_ptrs in a memory (image) device before
allocating new ones. This allows multiple calls to setup_buf_device
without leaking memory (as seen with the PCL allocator that does
not have garbage collection).


Modified: trunk/gs/src/gdevprn.c
===================================================================
--- trunk/gs/src/gdevprn.c	2007-03-04 16:37:32 UTC (rev 7758)
+++ trunk/gs/src/gdevprn.c	2007-03-04 16:41:00 UTC (rev 7759)
@@ -1081,6 +1081,13 @@
     if ((gx_device *)mdev == bdev && mdev->num_planes)
 	raster = bitmap_raster(mdev->planes[0].depth * mdev->width);
     if (ptrs == 0) {
+	/* 
+	 * Before allocating a new line pointer array, if there is a previous
+	 * array, free it to prevent leaks.
+	 */
+	if (mdev->line_ptrs != NULL)
+	    gs_free_object(mdev->line_pointer_memory, mdev->line_ptrs,
+		       "mem_close");
 	/*
 	 * Allocate line pointers now; free them when we close the device.
 	 * Note that for multi-planar devices, we have to allocate using



More information about the gs-cvs mailing list