From 2aae1cb84edeaf316f40a4a2b677db2a4a5848c0 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Wed, 10 Feb 2021 15:14:46 +0100 Subject: [PATCH] Fix #13235: NPE in fix_duplicated_banners() Co-authored-by: IntelOrca --- src/openrct2/world/Banner.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/openrct2/world/Banner.cpp b/src/openrct2/world/Banner.cpp index 9fdcfc5cd6..77b271253c 100644 --- a/src/openrct2/world/Banner.cpp +++ b/src/openrct2/world/Banner.cpp @@ -305,9 +305,13 @@ void fix_duplicated_banners() Guard::Assert(!activeBanners[newBannerIndex]); // Copy over the original banner, but update the location - auto& newBanner = *GetBanner(newBannerIndex); - newBanner = *GetBanner(bannerIndex); - newBanner.position = { x, y }; + auto newBanner = GetBanner(newBannerIndex); + auto oldBanner = GetBanner(bannerIndex); + if (oldBanner != nullptr && newBanner != nullptr) + { + *newBanner = *oldBanner; + newBanner->position = { x, y }; + } tileElement->AsBanner()->SetIndex(newBannerIndex); }