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
Contributor

commented Oct 9, 2019

Helps #9014

Copy link
Contributor

left a comment

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)

This comment has been minimized.

Copy link
@duncanspumpkin

duncanspumpkin Oct 9, 2019

Contributor

Why this change

This comment has been minimized.

Copy link
@duncanspumpkin

duncanspumpkin Oct 9, 2019

Contributor

This is already safe

This comment has been minimized.

Copy link
@tupaschoal

tupaschoal Oct 9, 2019

Author Contributor

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;

This comment has been minimized.

Copy link
@duncanspumpkin

duncanspumpkin Oct 9, 2019

Contributor

This has already been accounted for in the function

@tupaschoal

This comment has been minimized.

Copy link
Contributor Author

commented Oct 9, 2019

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 tupaschoal:nullptr-deref-avoid-path branch Oct 9, 2019
@duncanspumpkin

This comment has been minimized.

Copy link
Contributor

commented Oct 9, 2019

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
Projects
None yet
2 participants
You can’t perform that action at this time.