From d5426c37791ef4c3a35f3515e614ff86773a4cbe Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Sun, 7 Mar 2021 13:37:23 +0100 Subject: [PATCH] Fix #14123: NPE in map_obstruction_set_error_text() --- src/openrct2/world/Map.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 2d6de3c057..9b1be4a87f 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1215,7 +1215,8 @@ void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Resul sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); res.ErrorMessage = STR_X_IN_THE_WAY; auto ft = Formatter(res.ErrorMessageArgs.data()); - ft.Add(sceneryEntry->name); + rct_string_id stringId = sceneryEntry != nullptr ? sceneryEntry->name : static_cast(STR_EMPTY); + ft.Add(stringId); break; } case TILE_ELEMENT_TYPE_ENTRANCE: @@ -1237,7 +1238,8 @@ void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Resul sceneryEntry = tileElement->AsWall()->GetEntry(); res.ErrorMessage = STR_X_IN_THE_WAY; auto ft = Formatter(res.ErrorMessageArgs.data()); - ft.Add(sceneryEntry->name); + rct_string_id stringId = sceneryEntry != nullptr ? sceneryEntry->name : static_cast(STR_EMPTY); + ft.Add(stringId); break; } case TILE_ELEMENT_TYPE_LARGE_SCENERY: @@ -1245,7 +1247,8 @@ void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Resul sceneryEntry = tileElement->AsLargeScenery()->GetEntry(); res.ErrorMessage = STR_X_IN_THE_WAY; auto ft = Formatter(res.ErrorMessageArgs.data()); - ft.Add(sceneryEntry->name); + rct_string_id stringId = sceneryEntry != nullptr ? sceneryEntry->name : static_cast(STR_EMPTY); + ft.Add(stringId); break; } }