diff --git a/roadveh_gui.c b/roadveh_gui.c index 23c4758f19..06737a5019 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 959cbd0ec8..e90077aed6 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 41335d1b51..b590eb29b6 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);