From 79944d4f9065477b6b5c66dc734e5e07082bdab6 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Thu, 23 Jun 2011 17:44:04 -0400 Subject: [PATCH] fixed out-of-bounds index segfault --- src/rendermode-lighting.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rendermode-lighting.c b/src/rendermode-lighting.c index 0a92554..c515db5 100644 --- a/src/rendermode-lighting.c +++ b/src/rendermode-lighting.c @@ -88,6 +88,14 @@ estimate_blocklevel(RenderModeLighting *self, RenderState *state, for (dx = -1; dx <= 1; dx += 2) { for (dy = -1; dy <= 1; dy += 2) { for (dz = -1; dz <= 1; dz += 2) { + + /* skip if block is out of range */ + if (x+dx < 0 || x+dx >= 16 || + y+dy < 0 || y+dy >= 16 || + z+dz < 0 || z+dz >= 128) { + continue; + } + coeff = estimate_blocklevel(self, state, x+dx, y+dy, z+dz, &auth); local_block = getArrayByte3D(blocks, x+dx, y+dy, z+dz); /* only add if the block is transparent, this seems to look better than