From: Brian Paul Date: Fri, 28 May 2010 18:49:49 +0000 (-0600) Subject: llvmpipe: add out of memory checking to triangle setup path X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=151b3bb3af722f0e14e209171acc2239d3cf2817;p=mesa.git llvmpipe: add out of memory checking to triangle setup path --- diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c index 306cb6e27d2..34d71254b23 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c +++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c @@ -272,12 +272,14 @@ alloc_triangle(struct lp_scene *scene, unsigned nr_inputs, unsigned *tri_size) tri = lp_scene_alloc_aligned( scene, bytes, 16 ); - inputs = (char *) (tri + 1); - tri->inputs.a0 = (float (*)[4]) inputs; - tri->inputs.dadx = (float (*)[4]) (inputs + input_array_sz); - tri->inputs.dady = (float (*)[4]) (inputs + 2 * input_array_sz); + if (tri) { + inputs = (char *) (tri + 1); + tri->inputs.a0 = (float (*)[4]) inputs; + tri->inputs.dadx = (float (*)[4]) (inputs + input_array_sz); + tri->inputs.dady = (float (*)[4]) (inputs + 2 * input_array_sz); - *tri_size = bytes; + *tri_size = bytes; + } return tri; } @@ -341,6 +343,8 @@ do_triangle_ccw(struct lp_setup_context *setup, print_triangle(setup, v1, v2, v3); tri = alloc_triangle(scene, setup->fs.nr_inputs, &tri_bytes); + if (!tri) + return; #ifdef DEBUG tri->v[0][0] = v1[0][0];