From fb74d12f31c81116270f3898c93ecea2cbec13c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Mon, 30 Oct 2017 22:53:58 +0100 Subject: [PATCH] Fix NULL checks in facility_paint_setup --- src/openrct2/ride/shops/Facility.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/openrct2/ride/shops/Facility.cpp b/src/openrct2/ride/shops/Facility.cpp index 4f664c5202..a8de843972 100644 --- a/src/openrct2/ride/shops/Facility.cpp +++ b/src/openrct2/ride/shops/Facility.cpp @@ -34,13 +34,19 @@ static void facility_paint_setup(paint_session * session, uint8 rideIndex, uint8 { bool hasSupports = wooden_a_supports_paint_setup(session, direction & 1, 0, height, session->TrackColours[SCHEME_3], NULL); - Ride * ride = get_ride(rideIndex); - rct_ride_entry * rideEntry = get_ride_entry(ride->subtype); - rct_ride_entry_vehicle * firstVehicleEntry = &rideEntry->vehicles[0]; + Ride * ride = get_ride(rideIndex); + rct_ride_entry * rideEntry = get_ride_entry(ride->subtype); - if (rideEntry == NULL || firstVehicleEntry == NULL) + if (rideEntry == nullptr) { - log_error("Error drawing facility, rideEntry or firstVehicleEntry is NULL."); + log_error("Error drawing facility, rideEntry is NULL."); + return; + } + + rct_ride_entry_vehicle * firstVehicleEntry = &rideEntry->vehicles[0]; + if (firstVehicleEntry == nullptr) + { + log_error("Error drawing facility, firstVehicleEntry is NULL."); return; }