From 558d2356808bcc35a33bc001fe851f377273c071 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek <1478678+Gymnasiast@users.noreply.github.com> Date: Sun, 29 Sep 2024 16:21:26 +0200 Subject: [PATCH] Fix #22479: Crash when a ride has no valid music object --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/Ride.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 5a542c494b..f3f24b16ad 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -19,6 +19,7 @@ - Fix: [#22072] Objective date string and staff tenure date string cannot be reused on agglutinative languages. - Fix: [#22133] Ride time is incorrect for extremely slow speeds. - Fix: [#22231] Invalid object version can cause a crash. +- Fix: [#22479] Crash when a ride has no valid music object. - Fix: [#22562] Bottom row of pixels is not always drawn by the OpenGL renderer when zoomed in. - Fix: [#22653] Missing water tiles in RCT1 and RCT2 scenarios. - Fix: [#22654] Misplaced scenario elements in RCT1 and RCT2 scenarios. diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index f042db69e1..7a9fd0cbf1 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -5288,7 +5288,7 @@ namespace OpenRCT2::Ui::Windows // Do we have a preview image to draw? auto musicObj = ride->GetMusicObject(); - bool hasPreview = musicObj->HasPreview(); + bool hasPreview = musicObj != nullptr && musicObj->HasPreview(); if (!hasPreview) return; @@ -5321,6 +5321,9 @@ namespace OpenRCT2::Ui::Windows GfxClear(dpi, paletteIndex); auto* musicObj = ride->GetMusicObject(); + if (musicObj == nullptr) + return; + auto y = 0; for (size_t i = 0; i < musicObj->GetTrackCount(); i++)