diff options
author | Darkvater <darkvater@openttd.org> | 2006-10-31 21:15:56 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2006-10-31 21:15:56 +0000 |
commit | eadf788cc5d068622f20221566f4027625090689 (patch) | |
tree | f1aae895580a4a2bc7864f645fae39e9c2bc7669 /player_gui.c | |
parent | 993cb13c8dde55d77b732bba55bf3c94b0ea9216 (diff) | |
download | openttd-eadf788cc5d068622f20221566f4027625090689.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.c | 18 |
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; } |