From e2e4c1d942e4f0408b1b08ab0b708462cb13335e Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Tue, 9 Apr 2019 18:39:33 +0100 Subject: [PATCH] Fix #9079. Null derference checked for when getting banner element. Unsure how the save managed to get in this state --- src/openrct2/actions/BannerSetStyleAction.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/openrct2/actions/BannerSetStyleAction.hpp b/src/openrct2/actions/BannerSetStyleAction.hpp index 390db7c86f..50254ab9d0 100644 --- a/src/openrct2/actions/BannerSetStyleAction.hpp +++ b/src/openrct2/actions/BannerSetStyleAction.hpp @@ -96,6 +96,11 @@ public: } break; case BannerSetStyleType::NoEntry: + if (tileElement->AsBanner() == nullptr) + { + log_error("Tile element was not a banner."); + return MakeResult(GA_ERROR::UNKNOWN, STR_NONE); + } break; default: log_error("Invalid type: %u", _type); @@ -161,6 +166,12 @@ public: case BannerSetStyleType::NoEntry: { BannerElement* bannerElement = tileElement->AsBanner(); + if (bannerElement == nullptr) + { + log_error("Tile element was not a banner."); + return MakeResult(GA_ERROR::UNKNOWN, STR_NONE); + } + banner->flags &= ~BANNER_FLAG_NO_ENTRY; banner->flags |= (_parameter != 0) ? BANNER_FLAG_NO_ENTRY : 0; uint8_t allowedEdges = 0xF;