[Widelands-cvs] SF.net SVN: widelands:[4475] trunk/src/economy/cmd_call_economy_balance.cc
Status: Beta
Brought to you by:
sirver
From: <si...@us...> - 2009-08-10 01:35:04
|
Revision: 4475 http://widelands.svn.sourceforge.net/widelands/?rev=4475&view=rev Author: sigra Date: 2009-08-10 01:34:56 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Fix bug #2834682 (segmentation fault in Cmd_Call_Economy_Balance::Read). Modified Paths: -------------- trunk/src/economy/cmd_call_economy_balance.cc Modified: trunk/src/economy/cmd_call_economy_balance.cc =================================================================== --- trunk/src/economy/cmd_call_economy_balance.cc 2009-08-10 00:54:47 UTC (rev 4474) +++ trunk/src/economy/cmd_call_economy_balance.cc 2009-08-10 01:34:56 UTC (rev 4475) @@ -64,11 +64,14 @@ m_timerid = fr.Unsigned32(); } else if (packet_version == 1 || packet_version == 2) { GameLogicCommand::Read(fr, egbase, mol); - Player * const player = egbase.get_player(fr.Unsigned8()); - Economy * const economy = - fr.Unsigned8 () ? - player->get_economy_by_number(fr.Unsigned16()) : 0; - m_flag = &economy->get_arbitrary_flag(); + uint8_t const player_number = fr.Unsigned8(); + if (Player * const player = egbase.get_player(player_number)) { + Economy * const economy = + fr.Unsigned8 () ? + player->get_economy_by_number(fr.Unsigned16()) : 0; + m_flag = &economy->get_arbitrary_flag(); + } else + throw wexception("invalid player number %u", player_number); if (packet_version >= 2) m_timerid = fr.Unsigned32(); else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |