diff options
author | Jonathan G Rennison <j.g.rennison@gmail.com> | 2021-04-02 09:13:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-02 10:13:53 +0200 |
commit | 83ac5aa27ad5185d68e549d9be2134506009b1ae (patch) | |
tree | 962873bd1219d4e8cb0f3988eb0089e6dc83baf6 /src | |
parent | adb9fa3b36cf1031591363dcd3b6f591fd485ab0 (diff) | |
download | openttd-83ac5aa27ad5185d68e549d9be2134506009b1ae.tar.xz |
Fix: Memory leak of airport tile layout in AirportChangeInfo (prop 0A) (#8928)
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 7ac8bc945..46bd5a655 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -3862,6 +3862,7 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, B } case 0x0A: { // Set airport layout + byte old_num_table = as->num_table; free(as->rotation); as->num_table = buf->ReadByte(); // Number of layaouts as->rotation = MallocT<Direction>(as->num_table); @@ -3920,6 +3921,12 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, B tile_table[j] = CallocT<AirportTileTable>(size); memcpy(tile_table[j], copy_from, sizeof(*copy_from) * size); } + /* Free old layouts in the airport spec */ + for (int j = 0; j < old_num_table; j++) { + /* remove the individual layouts */ + free(as->table[j]); + } + free(as->table); /* Install final layout construction in the airport spec */ as->table = tile_table; free(att); |