Skip to content

Commit

Permalink
Dungeongen: Fix rarely triggered segfault
Browse files Browse the repository at this point in the history
A segfault exposed a missing 'vm->m_area.contains()'
check in makeCorridor that allowed the calculation
of vm index for a node outside the vm area. The huge
and invalid index number caused getContent to fail
  • Loading branch information
paramat committed Dec 1, 2015
1 parent 6fead28 commit 57b4295
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/dungeongen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ void DungeonGen::makeCorridor(v3s16 doorplace, v3s16 doordir,
if (partcount != 0)
p.Y += make_stairs;

if (vm->m_area.contains(p) && vm->m_area.contains(p + v3s16(0, 1, 0))) {
if (vm->m_area.contains(p) && vm->m_area.contains(p + v3s16(0, 1, 0)) &&
vm->m_area.contains(v3s16(p.X - dir.X, p.Y - 1, p.Z - dir.Z))) {
if (make_stairs) {
makeFill(p + v3s16(-1, -1, -1),
dp.holesize + v3s16(2, 3, 2),
Expand Down

0 comments on commit 57b4295

Please sign in to comment.