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

ray at ghostscript.com ray at ghostscript.com
Thu May 8 11:56:11 PDT 2008


Author: ray
Date: 2008-05-08 11:56:10 -0700 (Thu, 08 May 2008)
New Revision: 8714

Modified:
   trunk/gs/src/gxdhtserial.c
Log:
Fix memory leak observed with DEBUG=1 build on mtrender branch. The
'levels' and 'bit_data' of halftones were being leaked when halftones
were set by the clist reader.

DETAILS:

Since the 'dht.rc' was filled with 0's, the rc.memory would cause the
gx_imager_dev_ht_install to copy the order (mem_diff would be true).
The gx_ht_copy_ht_order would make a copy, but the one passed in
was never freed. Since the 'src' component information was cleared
during the install, gx_ht_read_and_install needs to save a copy of
the components so that the orders can be released.


Modified: trunk/gs/src/gxdhtserial.c
===================================================================
--- trunk/gs/src/gxdhtserial.c	2008-05-08 18:40:31 UTC (rev 8713)
+++ trunk/gs/src/gxdhtserial.c	2008-05-08 18:56:10 UTC (rev 8714)
@@ -622,6 +622,7 @@
     gs_memory_t *           mem )
 {
     gx_ht_order_component   components[GX_DEVICE_COLOR_MAX_COMPONENTS];
+    gx_ht_order_component   components_save[GX_DEVICE_COLOR_MAX_COMPONENTS];
     const byte *            data0 = data;
     gx_device_halftone      dht;
     int                     num_dev_comps;
@@ -656,8 +657,14 @@
     }
 
     /* if everything is OK, install the halftone */
-    if (code >= 0)
+    if (code >= 0) {
+	/* save since the 'install' copies the order, but then clears the source order	*/
+        for (i = 0; i < num_dev_comps; i++)
+	    components_save[i] = components[i];
         code = gx_imager_dev_ht_install(pis, &dht, dht.type, dev);
+        for (i = 0; i < num_dev_comps; i++)
+            gx_ht_order_release(&components_save[i].corder, mem, false);
+    }
 
     /*
      * If installation failed, discard the allocated elements. We can't



More information about the gs-cvs mailing list