Skip to content

Commit

Permalink
Fix OpenRCT2#8535, OpenRCT2#8480. Unintialised variable used to get p…
Browse files Browse the repository at this point in the history
…ath object.

When you try to mirror a track design that has a path object type that isn't loaded it will try to pass an uninitialised variable as the index of the path object. This will cause a bad pointer to be generated. Fix was to auto set it to zero and to be super careful reset it again to zero in the case when its not available
  • Loading branch information
duncanspumpkin committed Apr 2, 2019
1 parent eef6e7a commit 55dff7f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/openrct2/ride/TrackDesign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,16 @@ static void track_design_mirror_scenery(rct_track_td6* td6)
rct_td6_scenery_element* scenery = td6->scenery_elements;
for (; scenery != nullptr && scenery->scenery_object.end_flag != 0xFF; scenery++)
{
uint8_t entry_type, entry_index;
uint8_t entry_type{ 0 }, entry_index{ 0 };
if (!find_object_in_entry_group(&scenery->scenery_object, &entry_type, &entry_index))
{
entry_type = object_entry_get_type(&scenery->scenery_object);
if (entry_type != OBJECT_TYPE_PATHS)
{
continue;
}

entry_index = 0;
}

rct_scenery_entry* scenery_entry = (rct_scenery_entry*)object_entry_get_chunk(entry_type, entry_index);
Expand Down

0 comments on commit 55dff7f

Please sign in to comment.