1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-25 07:44:38 +01:00

Avoid dereferencing map_get_first_element_at nullptr on libopenrct2 (#10013)

* Avoid dereferencing map_get_first_element_at nullptr on Map.cpp

* Avoid dereferencing map_get_first_element_at nullptr on MapAnimation.cpp

Returning true or internal control variable, based on what was seen on `map_animation_invalidate_track_onridephoto`

* Avoid dereferencing map_get_first_element_at nullptr on Park.cpp

* Avoid dereferencing map_get_first_element_at nullptr on Scenery.cpp

* Avoid dereferencing map_get_first_element_at nullptr on Sprite.cpp

* Avoid dereferencing map_get_first_element_at nullptr on TileInspector.cpp

* Avoid dereferencing map_get_first_element_at nullptr on Wall.cpp

* Avoid dereferencing map_get_first_element_at nullptr on Fountain.cpp

* Avoid dereferencing map_get_first_element_at nullptr on Footpath.cpp

* Avoid dereferencing map_get_first_element_at nullptr on Entrance.cpp

* Avoid dereferencing map_get_first_element_at nullptr on Banner.cpp

* Avoid dereferencing map_get_first_element_at nullptr on Vehicle.cpp

* Avoid dereferencing map_get_first_element_at nullptr on TrackDesignSave.cpp

* Avoid dereferencing map_get_first_element_at nullptr on TrackDesign.cpp

* Avoid dereferencing map_get_first_element_at nullptr on Track.cpp

* Avoid dereferencing map_get_first_element_at nullptr on Station.cpp

* Avoid dereferencing map_get_first_element_at nullptr on RideRatings.cpp

* Avoid dereferencing map_get_first_element_at nullptr on Ride.cpp

* Avoid dereferencing map_get_first_element_at nullptr on S4Importer.cpp

* Avoid dereferencing map_get_first_element_at nullptr on Staff.cpp

* Avoid dereferencing map_get_first_element_at nullptr on Peep.cpp

* Avoid dereferencing map_get_first_element_at nullptr on GuestPathfinding.cpp

* Avoid dereferencing map_get_first_element_at nullptr on Guest.cpp

* Avoid dereferencing map_get_first_element_at nullptr on VirtualFloor.cpp

* Avoid dereferencing map_get_first_element_at nullptr on Paint.TileElement.cpp

* Fix issues raised on review

* Fix remaining review issues.

* Early exit on loops if tileElement is nullptr

* Fix clang-format issues
This commit is contained in:
Tulio Leao
2019-10-09 11:02:21 -03:00
committed by Duncan
parent 0a00f62e3a
commit b793d7e79a
25 changed files with 198 additions and 4 deletions

View File

@@ -91,6 +91,8 @@ void map_animation_invalidate_all()
static bool map_animation_invalidate_ride_entrance(int32_t x, int32_t y, int32_t baseZ)
{
auto tileElement = map_get_first_element_at(x >> 5, y >> 5);
if (tileElement == nullptr)
return true;
do
{
if (tileElement->base_height != baseZ)
@@ -125,6 +127,8 @@ static bool map_animation_invalidate_queue_banner(int32_t x, int32_t y, int32_t
TileElement* tileElement;
tileElement = map_get_first_element_at(x >> 5, y >> 5);
if (tileElement == nullptr)
return true;
do
{
if (tileElement->base_height != baseZ)
@@ -160,6 +164,8 @@ static bool map_animation_invalidate_small_scenery(int32_t x, int32_t y, int32_t
Peep* peep;
tileElement = map_get_first_element_at(x >> 5, y >> 5);
if (tileElement == nullptr)
return true;
do
{
if (tileElement->base_height != baseZ)
@@ -231,6 +237,8 @@ static bool map_animation_invalidate_park_entrance(int32_t x, int32_t y, int32_t
TileElement* tileElement;
tileElement = map_get_first_element_at(x >> 5, y >> 5);
if (tileElement == nullptr)
return true;
do
{
if (tileElement->base_height != baseZ)
@@ -259,6 +267,8 @@ static bool map_animation_invalidate_track_waterfall(int32_t x, int32_t y, int32
TileElement* tileElement;
tileElement = map_get_first_element_at(x >> 5, y >> 5);
if (tileElement == nullptr)
return true;
do
{
if (tileElement->base_height != baseZ)
@@ -286,6 +296,8 @@ static bool map_animation_invalidate_track_rapids(int32_t x, int32_t y, int32_t
TileElement* tileElement;
tileElement = map_get_first_element_at(x >> 5, y >> 5);
if (tileElement == nullptr)
return true;
do
{
if (tileElement->base_height != baseZ)
@@ -313,10 +325,10 @@ static bool map_animation_invalidate_track_onridephoto(int32_t x, int32_t y, int
TileElement* tileElement;
tileElement = map_get_first_element_at(x >> 5, y >> 5);
if (tileElement == nullptr)
return true;
do
{
if (tileElement == nullptr)
break;
if (tileElement->base_height != baseZ)
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
@@ -380,6 +392,8 @@ static bool map_animation_invalidate_track_spinningtunnel(int32_t x, int32_t y,
TileElement* tileElement;
tileElement = map_get_first_element_at(x >> 5, y >> 5);
if (tileElement == nullptr)
return true;
do
{
if (tileElement->base_height != baseZ)
@@ -417,6 +431,8 @@ static bool map_animation_invalidate_banner(int32_t x, int32_t y, int32_t baseZ)
TileElement* tileElement;
tileElement = map_get_first_element_at(x >> 5, y >> 5);
if (tileElement == nullptr)
return true;
do
{
if (tileElement->base_height != baseZ)
@@ -443,6 +459,8 @@ static bool map_animation_invalidate_large_scenery(int32_t x, int32_t y, int32_t
bool wasInvalidated = false;
tileElement = map_get_first_element_at(x >> 5, y >> 5);
if (tileElement == nullptr)
return true;
do
{
if (tileElement->base_height != baseZ)
@@ -476,6 +494,8 @@ static bool map_animation_invalidate_wall_door(int32_t x, int32_t y, int32_t bas
bool removeAnimation = true;
tileElement = map_get_first_element_at(x >> 5, y >> 5);
if (tileElement == nullptr)
return removeAnimation;
do
{
if (tileElement->base_height != baseZ)
@@ -536,6 +556,8 @@ static bool map_animation_invalidate_wall(int32_t x, int32_t y, int32_t baseZ)
bool wasInvalidated = false;
tileElement = map_get_first_element_at(x >> 5, y >> 5);
if (tileElement == nullptr)
return true;
do
{
if (tileElement->base_height != baseZ)