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

free() called on static airport rotation data (regression in r27907) #6627

Closed
DorpsGek opened this issue Oct 13, 2017 · 1 comment
Closed
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

JGR opened the ticket and wrote:

In src/table/airport_defaults.h, _origin_airport_specs is initialised with rotation data pointer set to reference _default_airports_rotation, which is declared as `static const Direction _default_airports_rotation[]`.

In src/newgrf.cpp AirportChangeInfo() (case for prop 0x08: Modify original airport), a new AirportSpec is allocated and initialised by copying an AirportSpec in _origin_airport_specs, this includes the rotation data pointer, pointing at static data.

In src/newgrf.cpp ResetCustomAirports() the rotation data pointer in the AirportSpec allocated in AirportChangeInfo() is freed.
As this is not a valid pointer returned by malloc() (or null) the program aborts.
This call to free() was added in r27907.

The other malloced fields of AirportSpec are correctly handled by mallocing copies in DuplicateTileTable().

I've attached a suggested fix which removes the issue without re-adding the leak fixed in r27907.

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/6627
@DorpsGek
Copy link
Member Author

DorpsGek commented Mar 6, 2018

peter1138 closed the ticket.

Reason for closing: Implemented

Fixed in r27974


This comment was imported from FlySpray: https://bugs.openttd.org/task/6627

@DorpsGek DorpsGek closed this as completed Mar 6, 2018
@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant