Skip to content

Commit

Permalink
Fix crash in layer_terrain
Browse files Browse the repository at this point in the history
Check that there is a group before trying to dereference it. The user may not
have provided one.

Closes #2017.
  • Loading branch information
lmoureaux committed Dec 27, 2023
1 parent 434d7ef commit 78f0bbf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion client/tileset/layer_terrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,12 @@ int layer_terrain::terrain_group(const terrain *pterrain) const
return -1;
}

return m_terrain_info.at(terrain_index(pterrain)).group->number;
auto group = m_terrain_info.at(terrain_index(pterrain)).group;
if (!group) {
return -1;
}

return group->number;
}

namespace /* anonymous */ {
Expand Down

0 comments on commit 78f0bbf

Please sign in to comment.