mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Fix: Memory leak of airport tile layout in AirportChangeInfo (prop 0A) (#8928)
This commit is contained in:
parent
adb9fa3b36
commit
83ac5aa27a
@ -3862,6 +3862,7 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, B
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 0x0A: { // Set airport layout
|
case 0x0A: { // Set airport layout
|
||||||
|
byte old_num_table = as->num_table;
|
||||||
free(as->rotation);
|
free(as->rotation);
|
||||||
as->num_table = buf->ReadByte(); // Number of layaouts
|
as->num_table = buf->ReadByte(); // Number of layaouts
|
||||||
as->rotation = MallocT<Direction>(as->num_table);
|
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);
|
tile_table[j] = CallocT<AirportTileTable>(size);
|
||||||
memcpy(tile_table[j], copy_from, sizeof(*copy_from) * 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 */
|
/* Install final layout construction in the airport spec */
|
||||||
as->table = tile_table;
|
as->table = tile_table;
|
||||||
free(att);
|
free(att);
|
||||||
|
Loading…
Reference in New Issue
Block a user