mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-22 23:33:04 +01:00
Fix bounds checks and a nullptr check
This commit is contained in:
@@ -1330,7 +1330,7 @@ void WindowSceneryScrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scr
|
||||
|
||||
auto numColumns = WindowSceneryGetNumColumns(w);
|
||||
auto tabIndex = gWindowSceneryActiveTabIndex;
|
||||
if (tabIndex > _tabEntries.size())
|
||||
if (tabIndex >= _tabEntries.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1082,7 +1082,7 @@ void window_zoom_out(rct_window* w, bool atCursor)
|
||||
void main_window_zoom(bool zoomIn, bool atCursor)
|
||||
{
|
||||
auto* mainWindow = window_get_main();
|
||||
if (mainWindow != nullptr)
|
||||
if (mainWindow == nullptr)
|
||||
return;
|
||||
|
||||
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
|
||||
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
|
||||
void RemoveString(rct_string_id stringId) override
|
||||
{
|
||||
if (_strings.size() >= static_cast<size_t>(stringId))
|
||||
if (_strings.size() > static_cast<size_t>(stringId))
|
||||
{
|
||||
_strings[stringId] = std::string();
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
|
||||
void SetString(rct_string_id stringId, const std::string& str) override
|
||||
{
|
||||
if (_strings.size() >= static_cast<size_t>(stringId))
|
||||
if (_strings.size() > static_cast<size_t>(stringId))
|
||||
{
|
||||
_strings[stringId] = str;
|
||||
}
|
||||
|
||||
@@ -678,10 +678,11 @@ bool track_block_get_previous(const CoordsXYE& trackPos, track_begin_end* outTra
|
||||
return false;
|
||||
|
||||
auto trackElement = trackPos.element->AsTrack();
|
||||
const auto& ted = GetTrackElementDescriptor(trackElement->GetTrackType());
|
||||
if (trackElement == nullptr)
|
||||
return false;
|
||||
|
||||
const auto& ted = GetTrackElementDescriptor(trackElement->GetTrackType());
|
||||
|
||||
auto rideIndex = trackElement->GetRideIndex();
|
||||
auto ride = get_ride(rideIndex);
|
||||
if (ride == nullptr)
|
||||
|
||||
@@ -98,7 +98,7 @@ std::unique_ptr<TitleSequence> LoadTitleSequence(const std::string& path)
|
||||
std::unique_ptr<TitleSequenceParkHandle> TitleSequenceGetParkHandle(const TitleSequence& seq, size_t index)
|
||||
{
|
||||
std::unique_ptr<TitleSequenceParkHandle> handle;
|
||||
if (index <= seq.Saves.size())
|
||||
if (index < seq.Saves.size())
|
||||
{
|
||||
const auto& filename = seq.Saves[index];
|
||||
if (seq.IsZip)
|
||||
|
||||
Reference in New Issue
Block a user