mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-10 08:00:05 +00:00
(svn r22057) -Fix: waypoint conversion could (previously) silently overfill the pool and crash
This commit is contained in:
parent
246f6fe478
commit
13fd2cd335
@ -75,6 +75,9 @@ void MoveBuoysToWaypoints()
|
|||||||
/* Delete the station, so we can make it a real waypoint. */
|
/* Delete the station, so we can make it a real waypoint. */
|
||||||
delete st;
|
delete st;
|
||||||
|
|
||||||
|
/* Stations and waypoints are in the same pool, so if a station
|
||||||
|
* is deleted there must be place for a Waypoint. */
|
||||||
|
assert(Waypoint::CanAllocateItem());
|
||||||
Waypoint *wp = new (index) Waypoint(xy);
|
Waypoint *wp = new (index) Waypoint(xy);
|
||||||
wp->town = town;
|
wp->town = town;
|
||||||
wp->string_id = train ? STR_SV_STNAME_WAYPOINT : STR_SV_STNAME_BUOY;
|
wp->string_id = train ? STR_SV_STNAME_WAYPOINT : STR_SV_STNAME_BUOY;
|
||||||
|
@ -93,6 +93,8 @@ void MoveWaypointsToBaseStations()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Waypoint::CanAllocateItem(_old_waypoints.Length())) SlError(STR_ERROR_TOO_MANY_STATIONS_LOADING);
|
||||||
|
|
||||||
/* All saveload conversions have been done. Create the new waypoints! */
|
/* All saveload conversions have been done. Create the new waypoints! */
|
||||||
for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) {
|
for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) {
|
||||||
Waypoint *new_wp = new Waypoint(wp->xy);
|
Waypoint *new_wp = new Waypoint(wp->xy);
|
||||||
|
Loading…
Reference in New Issue
Block a user