summaryrefslogtreecommitdiff
path: root/station_gui.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-11-18 16:47:02 +0000
committerDarkvater <darkvater@openttd.org>2006-11-18 16:47:02 +0000
commitb3c48c0a84323838b5104e422d11b8a1250325c8 (patch)
tree8112ec497b55f459780ad628193295c31cabfe28 /station_gui.c
parentaa97b61a27cecfb6e06526fa74d95629cc7259a5 (diff)
downloadopenttd-b3c48c0a84323838b5104e422d11b8a1250325c8.tar.xz
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
structs inside their array, and possibly invalidating pointers higher up. Meaning that any function called within an wndproc could cause unknown/invalid pointers once control was returned to this function. Solved by the introduction of an extra abstraction layer, an array of z-window positions that is only concerned with the pointers.
Diffstat (limited to 'station_gui.c')
-rw-r--r--station_gui.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/station_gui.c b/station_gui.c
index fbc8882b5..d41a16664 100644
--- a/station_gui.c
+++ b/station_gui.c
@@ -148,9 +148,10 @@ assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(plstations_d));
void RebuildStationLists(void)
{
- Window *w;
+ Window* const *wz;
- for (w = _windows; w != _last_window; ++w) {
+ FOR_ALL_WINDOWS(wz) {
+ Window *w = *wz;
if (w->window_class == WC_STATION_LIST) {
WP(w, plstations_d).flags |= SL_REBUILD;
SetWindowDirty(w);
@@ -160,9 +161,10 @@ void RebuildStationLists(void)
void ResortStationLists(void)
{
- Window *w;
+ Window* const *wz;
- for (w = _windows; w != _last_window; ++w) {
+ FOR_ALL_WINDOWS(wz) {
+ Window *w = *wz;
if (w->window_class == WC_STATION_LIST) {
WP(w, plstations_d).flags |= SL_RESORT;
SetWindowDirty(w);