From 9a23234631facb506fa107a3dbfc75502f1b6f40 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 11 Jun 2019 05:23:18 +0200 Subject: [PATCH] Fix #9388: Crash using set grass length cheat --- src/openrct2/actions/SetCheatAction.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/openrct2/actions/SetCheatAction.hpp b/src/openrct2/actions/SetCheatAction.hpp index 06ed56b4f3..9835ec4946 100644 --- a/src/openrct2/actions/SetCheatAction.hpp +++ b/src/openrct2/actions/SetCheatAction.hpp @@ -356,7 +356,11 @@ private: { for (x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++) { - auto surfaceElement = map_get_surface_element_at(x, y)->AsSurface(); + auto tileElement = map_get_surface_element_at(x, y); + if (tileElement == nullptr) + continue; + + auto surfaceElement = tileElement->AsSurface(); if (surfaceElement != nullptr && (surfaceElement->GetOwnership() & OWNERSHIP_OWNED) && surfaceElement->GetWaterHeight() == 0 && surfaceElement->CanGrassGrow()) {