aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2013-12-01 08:57:35 -0500
committerkwolekr <kwolekr@minetest.net>2013-12-01 08:57:35 -0500
commitf3439c40d85967c4f66eeefbc325f9ebf94d75e1 (patch)
treee2b71124df1218ad1c880c22e06111e4e2137573
parent20e3d550fa3ec42a065f7c776a2f9be9bc364503 (diff)
downloadminetest-f3439c40d85967c4f66eeefbc325f9ebf94d75e1.tar.gz
minetest-f3439c40d85967c4f66eeefbc325f9ebf94d75e1.tar.bz2
minetest-f3439c40d85967c4f66eeefbc325f9ebf94d75e1.zip
Cavegen: Fix possible out-of-bounds heightmap access
-rw-r--r--src/cavegen.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cavegen.cpp b/src/cavegen.cpp
index 71f005d5b..f04c02db9 100644
--- a/src/cavegen.cpp
+++ b/src/cavegen.cpp
@@ -518,7 +518,8 @@ void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
v3s16 p(cp.X + x0, cp.Y + y0, cp.Z + z0);
p += of;
- if (!is_ravine && mg->heightmap && should_make_cave_hole) {
+ if (!is_ravine && mg->heightmap && should_make_cave_hole &&
+ p.X <= node_max.X && p.Z <= node_max.Z) {
int maplen = node_max.X - node_min.X + 1;
int idx = (p.Z - node_min.Z) * maplen + (p.X - node_min.X);
if (p.Y >= mg->heightmap[idx] - 2)