Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid dereferencing map_get_path_element_at nullptr on libopenrct2 #10068

Closed

Conversation

tupaschoal
Copy link
Member

Helps #9014

Copy link
Contributor

@duncanspumpkin duncanspumpkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think either of the changes in this pr are required

@@ -761,7 +761,7 @@ bool Peep::Place(TileCoordsXYZ location, bool apply)
{
auto* pathElement = map_get_path_element_at(location);
TileElement* tileElement = reinterpret_cast<TileElement*>(pathElement);
if (!pathElement)
if (!tileElement)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already safe

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured it would be better to check for the tileElement as it's what will be used.

@@ -9884,6 +9884,9 @@ void vehicle_update_crossings(const rct_vehicle* vehicle)
while (true)
{
auto* pathElement = map_get_path_element_at({ xyElement.x / 32, xyElement.y / 32, xyElement.element->base_height });
if (pathElement == nullptr)
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has already been accounted for in the function

@tupaschoal
Copy link
Member Author

I don't think either of the changes in this pr are required

Yeah, seems not to, I'll close it then.

@tupaschoal tupaschoal closed this Oct 9, 2019
@tupaschoal tupaschoal deleted the nullptr-deref-avoid-path branch October 9, 2019 14:14
@duncanspumpkin
Copy link
Contributor

Good work anyway for exhausting all of the possibilities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants