summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-01-03 22:07:40 +0000
committertron <tron@openttd.org>2005-01-03 22:07:40 +0000
commit815bac212ae436cdef4ef2fe8723f18f1a0a5fbc (patch)
treef79b543714e7dc1d8c4d3ce99194c94edb45f994
parent036b043f9fa0e8284b66d1fc64fc5ed71ffe4ef8 (diff)
downloadopenttd-815bac212ae436cdef4ef2fe8723f18f1a0a5fbc.tar.xz
(svn r1358) Assert bounds of depot list when searching for a depot
-rw-r--r--roadveh_gui.c4
-rw-r--r--ship_gui.c4
-rw-r--r--train_gui.c4
3 files changed, 9 insertions, 3 deletions
diff --git a/roadveh_gui.c b/roadveh_gui.c
index 23c4758f1..06737a501 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -512,7 +512,9 @@ static void DrawRoadDepotWindow(Window *w)
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap);
/* locate the depot struct */
- for(d=_depots; d->xy != (TileIndex)tile; d++) {}
+ for (d = _depots; d->xy != (TileIndex)tile; d++) {
+ assert(d < endof(_depots);
+ }
SetDParam(0, d->town_index);
DrawWindowWidgets(w);
diff --git a/ship_gui.c b/ship_gui.c
index 959cbd0ec..e90077aed 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -646,7 +646,9 @@ static void DrawShipDepotWindow(Window *w)
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap);
/* locate the depot struct */
- for(d=_depots; d->xy != (TileIndex)tile; d++) {}
+ for (d = _depots; d->xy != (TileIndex)tile; d++) {
+ assert(d < endof(_depots);
+ }
SetDParam(0, d->town_index);
DrawWindowWidgets(w);
diff --git a/train_gui.c b/train_gui.c
index 41335d1b5..b590eb29b 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -333,7 +333,9 @@ static void DrawTrainDepotWindow(Window *w)
SetHScrollCount(w, hnum);
/* locate the depot struct */
- for(d=_depots; d->xy != (TileIndex)tile; d++) {}
+ for (d = _depots; d->xy != (TileIndex)tile; d++) {
+ assert(d < endof(_depots);
+ }
SetDParam(0, d->town_index);
DrawWindowWidgets(w);