Mesa (thalloc): thalloc: Fix realloc on orphan blocks

Jakob Bornecrantz wallbraker at kemper.freedesktop.org
Wed Jan 19 01:30:39 UTC 2011


Module: Mesa
Branch: thalloc
Commit: 0b0c16a5ab8107af99bea8f2adaf464fc4ecb3b5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b0c16a5ab8107af99bea8f2adaf464fc4ecb3b5

Author: Jakob Bornecrantz <jakob at vmware.com>
Date:   Wed Jan 19 02:28:41 2011 +0100

thalloc: Fix realloc on orphan blocks

This actually looks like its a bug from halloc that piglit valgrind tests
unsurfaced, the sequence that triggers it looks like this:

void *ptr = halloc(NULL, 1);
ptr = halloc(ptr, 2);

Signed-off-by: Jakob Bornecrantz <jakob at vmware.com>

---

 src/thalloc/halloc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/thalloc/halloc.c b/src/thalloc/halloc.c
index d71f328..256b2c3 100644
--- a/src/thalloc/halloc.c
+++ b/src/thalloc/halloc.c
@@ -101,7 +101,10 @@ void * halloc(void * ptr, size_t len)
 		if (! p)
 			return NULL;
 
-		hlist_relink(&p->siblings);
+		if (!p->parent)
+			hlist_init_item(&p->siblings);
+		else
+			hlist_relink(&p->siblings);
 		hlist_relink_head(&p->children);
 
 		hlist_for_each_safe(i, tmp, &p->children)




More information about the mesa-commit mailing list