summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2006-10-06 23:17:04 +0000
committerglx <glx@openttd.org>2006-10-06 23:17:04 +0000
commitf7a5a4219c8f17e14ece1695949711dd71b8211c (patch)
tree31d82b1b11fd2c636a1cc0f25300053092dc6adc
parentac0bada035e538fc6f329882ceb0794bbcb80d7f (diff)
downloadopenttd-f7a5a4219c8f17e14ece1695949711dd71b8211c.tar.xz
(svn r6674) -Fix r6631: two loops had incorrect behaviour (out of bound access in widget arrays)
-rw-r--r--graph_gui.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/graph_gui.c b/graph_gui.c
index 0f3b1caaa..621674edf 100644
--- a/graph_gui.c
+++ b/graph_gui.c
@@ -224,10 +224,9 @@ static void GraphLegendWndProc(Window *w, WindowEvent *e)
switch (e->event) {
case WE_CREATE: {
- uint include_bits = ~_legend_excludebits;
int i;
- for (i = 0; include_bits != 0; i++, include_bits >>= 1) {
- if (HASBIT(include_bits, 0)) LowerWindowWidget(w, i + 3);
+ for (i = 0; w->widget[i + 3].type != WWT_LAST; i++) {
+ if (!HASBIT(_legend_excludebits, i)) LowerWindowWidget(w, i + 3);
}
break;
}
@@ -706,10 +705,9 @@ static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
case WE_CREATE: {
- uint to_select = ~_legend_cargobits;
int i;
- for (i = 0; to_select != 0; i++, to_select >>= 1) {
- if (HASBIT(to_select, 0)) LowerWindowWidget(w, i + 3);
+ for (i = 0; w->widget[i + 3].type != WWT_LAST; i++) {
+ if (!HASBIT(_legend_cargobits, i)) LowerWindowWidget(w, i + 3);
}
break;
}