From 78f0bbf9fab92cbeceaa7a2cff14109d8e642838 Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Wed, 27 Dec 2023 01:55:11 +0100 Subject: [PATCH] Fix crash in layer_terrain Check that there is a group before trying to dereference it. The user may not have provided one. Closes #2017. --- client/tileset/layer_terrain.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/tileset/layer_terrain.cpp b/client/tileset/layer_terrain.cpp index d781f2f08d..2fb4da25f0 100644 --- a/client/tileset/layer_terrain.cpp +++ b/client/tileset/layer_terrain.cpp @@ -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 */ {