Skip to content

Commit f3439c4

Browse files
committedDec 1, 2013
Cavegen: Fix possible out-of-bounds heightmap access
1 parent 20e3d55 commit f3439c4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎src/cavegen.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,8 @@ void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
518518
v3s16 p(cp.X + x0, cp.Y + y0, cp.Z + z0);
519519
p += of;
520520

521-
if (!is_ravine && mg->heightmap && should_make_cave_hole) {
521+
if (!is_ravine && mg->heightmap && should_make_cave_hole &&
522+
p.X <= node_max.X && p.Z <= node_max.Z) {
522523
int maplen = node_max.X - node_min.X + 1;
523524
int idx = (p.Z - node_min.Z) * maplen + (p.X - node_min.X);
524525
if (p.Y >= mg->heightmap[idx] - 2)

0 commit comments

Comments
 (0)
Please sign in to comment.