Mesa (master): ralloc: Fix ralloc_parent() of memory allocated out of the NULL context.

Kenneth Graunke kwg at kemper.freedesktop.org
Thu May 31 05:02:48 UTC 2012


Module: Mesa
Branch: master
Commit: 1559b2e2d7c0d9ddab0e186fcf855ea847152ef1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1559b2e2d7c0d9ddab0e186fcf855ea847152ef1

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Mon May 21 19:34:13 2012 -0700

ralloc: Fix ralloc_parent() of memory allocated out of the NULL context.

If an object is allocated out of the NULL context, info->parent will be
NULL.  Using the PTR_FROM_HEADER macro would be incorrect: it would say
that ralloc_parent(ralloc_context(NULL)) == sizeof(ralloc_header).

Fixes the new "null_parent" unit test.

NOTE: This is a candidate for the 7.9, 7.10, 7.11, and 8.0 branches.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/glsl/ralloc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/glsl/ralloc.c b/src/glsl/ralloc.c
index 2f93dcd..3da09b5 100644
--- a/src/glsl/ralloc.c
+++ b/src/glsl/ralloc.c
@@ -278,7 +278,7 @@ ralloc_parent(const void *ptr)
       return NULL;
 
    info = get_header(ptr);
-   return PTR_FROM_HEADER(info->parent);
+   return info->parent ? PTR_FROM_HEADER(info->parent) : NULL;
 }
 
 static void *autofree_context = NULL;




More information about the mesa-commit mailing list