[xf86-video-intel] pI830->memory_manager is freed twice

Keith Packard keithp at keithp.com
Mon Oct 8 18:23:31 PDT 2007


Just want to get feedback on whether this will create some kind of nasty
leak. I was trashing the libc memory allocator with a double free before
I did this...

commit 751604506176b25d3262639d08680d927c566308
Author: Keith Packard <keithp at koto.keithp.com>
Date:   Mon Oct 8 18:22:10 2007 -0700

    Leave freeing pI830->memory_manager until we're done with it.
    
    pI830->memory_manager is the DRM memory management segment, and is used
    while cleaning up the X server memory allocations. Freeing it before the
    rest of the memory allocator is cleaned up turns out to be a bad idea.

diff --git a/src/i830_memory.c b/src/i830_memory.c
index cdb7c47..5fc2043 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -267,10 +267,20 @@ i830_reset_allocations(ScrnInfoPtr pScrn)
 {
     I830Ptr pI830 = I830PTR(pScrn);
     int	    p;
+    i830_memory	*mem, *this;
 
     /* While there is any memory between the start and end markers, free it. */
-    while (pI830->memory_list->next->next != NULL)
-	i830_free_memory(pScrn, pI830->memory_list->next);
+    for (mem = pI830->memory_list->next; mem->next != NULL;)
+    {
+	this = mem;
+	mem = mem->next;
+#ifdef XF86DRI_MM
+	/* Don't free the DRI memory manager segment; that is still needed */
+	if (this == pI830->memory_manager)
+	    continue;
+#endif
+	i830_free_memory(pScrn, this);
+    }
 
     /* Free any allocations in buffer objects */
 #ifdef XF86DRI_MM

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg/attachments/20071008/9cf5cde6/attachment.pgp>


More information about the xorg mailing list