From 8184228e8b894b434a87387c79d9a11a50684272 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 9 Nov 2011 19:29:37 +0000 Subject: [PATCH] llvmpipe: Make more resilient to out-of-memory situations. Most of the code was alright, but we were missing a few paths. Reviewed-by: Brian Paul --- src/gallium/drivers/llvmpipe/lp_texture.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 8fac77b0c57..e895485e947 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -978,7 +978,9 @@ alloc_image_data(struct llvmpipe_resource *lpr, unsigned level, /* tiled data is stored in regular memory */ uint buffer_size = tex_image_size(lpr, level, layout); lpr->tiled[level].data = align_malloc(buffer_size, alignment); - memset(lpr->tiled[level].data, 0, buffer_size); + if (lpr->tiled[level].data) { + memset(lpr->tiled[level].data, 0, buffer_size); + } } else { assert(layout == LP_TEX_LAYOUT_LINEAR); @@ -997,7 +999,9 @@ alloc_image_data(struct llvmpipe_resource *lpr, unsigned level, /* not a display target - allocate regular memory */ uint buffer_size = tex_image_size(lpr, level, LP_TEX_LAYOUT_LINEAR); lpr->linear[level].data = align_malloc(buffer_size, alignment); - memset(lpr->linear[level].data, 0, buffer_size); + if (lpr->linear[level].data) { + memset(lpr->linear[level].data, 0, buffer_size); + } } } } -- 2.30.2