From: José Fonseca Date: Wed, 9 Nov 2011 19:29:37 +0000 (+0000) Subject: llvmpipe: Make more resilient to out-of-memory situations. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8184228e8b894b434a87387c79d9a11a50684272;p=mesa.git 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 --- 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); + } } } }