summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-02-11 09:33:38 +0000
committerrubidium <rubidium@openttd.org>2011-02-11 09:33:38 +0000
commit13fd2cd335f1162758348ae3e2e9c2a1a4cc5602 (patch)
tree55c0784a6649bc1b18980ff53964d7f1e49be49f /src
parent246f6fe478ca018ce7d26e99b22ea8a3b97fc973 (diff)
downloadopenttd-13fd2cd335f1162758348ae3e2e9c2a1a4cc5602.tar.xz
(svn r22057) -Fix: waypoint conversion could (previously) silently overfill the pool and crash
Diffstat (limited to 'src')
-rw-r--r--src/saveload/station_sl.cpp3
-rw-r--r--src/saveload/waypoint_sl.cpp2
2 files changed, 5 insertions, 0 deletions
diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp
index 330425024..e41cb3288 100644
--- a/src/saveload/station_sl.cpp
+++ b/src/saveload/station_sl.cpp
@@ -75,6 +75,9 @@ void MoveBuoysToWaypoints()
/* Delete the station, so we can make it a real waypoint. */
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);
wp->town = town;
wp->string_id = train ? STR_SV_STNAME_WAYPOINT : STR_SV_STNAME_BUOY;
diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp
index 3dce9e3d5..9d1f164b4 100644
--- a/src/saveload/waypoint_sl.cpp
+++ b/src/saveload/waypoint_sl.cpp
@@ -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! */
for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) {
Waypoint *new_wp = new Waypoint(wp->xy);