summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2013-04-17 11:07:49 +1000
committerIan Romanick <ian.d.romanick@intel.com>2013-05-10 16:41:31 -0700
commited00ea344490145a3f3eb7aa010ad8f593325929 (patch)
treeed1ba7f626bd119938c3c6ea34704a282304156c
parent1665f29c29b368988e1ad8b78acda444621aed37 (diff)
ralloc: don't write to memory in case of alloc fail.
For some reason I made this happen under indirect rendering, I think we might have a leak, valgrind gave out, so I said I'd fix the basic problem. NOTE: This is a candidate for stable branches. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Signed-off-by: Dave Airlie <airlied@redhat.com> (cherry picked from commit 47bd6e46fe89e1cce61b11bcaa7b81f807011c23)
-rw-r--r--src/glsl/ralloc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/glsl/ralloc.c b/src/glsl/ralloc.c
index 59e71c48b00..02816425221 100644
--- a/src/glsl/ralloc.c
+++ b/src/glsl/ralloc.c
@@ -108,6 +108,8 @@ ralloc_size(const void *ctx, size_t size)
{
void *block = calloc(1, size + sizeof(ralloc_header));
+ if (unlikely(block == NULL))
+ return NULL;
ralloc_header *info = (ralloc_header *) block;
ralloc_header *parent = ctx != NULL ? get_header(ctx) : NULL;