Skip to content

Commit

Permalink
fixup potential null dereference in server code
Browse files Browse the repository at this point in the history
If a client submitted a bad message it would cause the server to
crash.

Issue found by coverity.
  • Loading branch information
cbeck88 committed Jun 29, 2014
1 parent 9ba544c commit cc04fc4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/server/game.cpp
Expand Up @@ -1542,9 +1542,13 @@ void game::set_termination_reason(const std::string& reason) {

void game::allow_global(const simple_wml::document &data) {
const simple_wml::node *cfg = data.root().child("wait_global");
int side = (*cfg)["side"].to_int();
if ((side < 0) || (side > nsides_)) side = 0;
global_wait_side_ = side;
if (!cfg) {
int side = (*cfg)["side"].to_int();
if ((side < 0) || (side > nsides_)) side = 0;
global_wait_side_ = side;
} else {
WRN_GAME << "game::allow_global: received a malformed message from client, no child \"wait_global\" in config argument" << std::endl;
}
}

const user_vector game::all_game_users() const {
Expand Down

0 comments on commit cc04fc4

Please sign in to comment.