Lua API: Fix crash if passing an out-of-bounds side to wesnoth.interface.end_turn
This commit is contained in:
parent
c90f13cf77
commit
4426f9740f
1 changed files with 3 additions and 2 deletions
|
@ -1671,8 +1671,9 @@ int game_lua_kernel::intf_end_turn(lua_State* L)
|
|||
//note that next_player_number = 1, next_player_number = nteams+1 both set the next team to be the first team
|
||||
//but the later will make the turn counter change aswell fire turn end events accoringly etc.
|
||||
if (!lua_isnoneornil(L, 1)) {
|
||||
int npn = luaL_checknumber(L, 1);
|
||||
if (npn <= 0 /*TODO: || npn > 2*nteams*/) {
|
||||
int max = 2 * teams().size();
|
||||
int npn = luaL_checkinteger(L, 1);
|
||||
if (npn <= 0 || npn > max) {
|
||||
return luaL_argerror(L, 1, "side number out of range");
|
||||
}
|
||||
resources::controller->gamestate().next_player_number_ = npn;
|
||||
|
|
Loading…
Add table
Reference in a new issue