summaryrefslogtreecommitdiff
path: root/player_gui.c
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2006-10-31 21:15:56 +0000
committerDarkvater <Darkvater@openttd.org>2006-10-31 21:15:56 +0000
commit0e1485f55e692478c3bf9dbca428a46c1ac20cd4 (patch)
treef1aae895580a4a2bc7864f645fae39e9c2bc7669 /player_gui.c
parentb2c7a408edab0317d1d67c1d5d9ef8f0043f5291 (diff)
downloadopenttd-0e1485f55e692478c3bf9dbca428a46c1ac20cd4.tar.xz
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
invalid players (eg spectators) which could lead to crashes.
Diffstat (limited to 'player_gui.c')
-rw-r--r--player_gui.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/player_gui.c b/player_gui.c
index 4ec06e7c3..798c805bb 100644
--- a/player_gui.c
+++ b/player_gui.c
@@ -219,24 +219,24 @@ static const WindowDesc _other_player_finances_small_desc = {
PlayerFinancesWndProc
};
-static const WindowDesc * const desc_table[2*2] = {
- &_player_finances_desc,&_player_finances_small_desc,
- &_other_player_finances_desc,&_other_player_finances_small_desc,
-};
-
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied)
{
Window *w;
int mode;
+ static const WindowDesc * const desc_table[2 * 2] = {
+ &_player_finances_desc, &_player_finances_small_desc,
+ &_other_player_finances_desc, &_other_player_finances_small_desc,
+ };
+
+ if (!IsValidPlayer(player)) return;
+
mode = (player != _local_player) * 2 + show_small;
w = AllocateWindowDescFront(desc_table[mode], player);
if (w != NULL) {
w->caption_color = w->window_number;
WP(w,def_d).data_1 = mode;
- if (show_stickied) {
- w->flags4 |= WF_STICKY;
- }
+ if (show_stickied) w->flags4 |= WF_STICKY;
}
}
@@ -878,6 +878,8 @@ void ShowPlayerCompany(PlayerID player)
{
Window *w;
+ if (!IsValidPlayer(player)) return;
+
w = AllocateWindowDescFront(&_player_company_desc, player);
if (w != NULL) w->caption_color = w->window_number;
}