Fix #2253: crash when accessing out-of-range attack from Lua
This commit is contained in:
parent
dcd93bbd13
commit
6cd2a9b7cd
1 changed files with 12 additions and 4 deletions
|
@ -49,14 +49,22 @@ void push_unit_attacks_table(lua_State* L, int idx)
|
|||
|
||||
void luaW_pushweapon(lua_State* L, attack_ptr weapon)
|
||||
{
|
||||
new(L) attack_ref(weapon);
|
||||
luaL_setmetatable(L, uattackKey);
|
||||
if(weapon != nullptr) {
|
||||
new(L) attack_ref(weapon);
|
||||
luaL_setmetatable(L, uattackKey);
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
}
|
||||
|
||||
void luaW_pushweapon(lua_State* L, const_attack_ptr weapon)
|
||||
{
|
||||
new(L) attack_ref(weapon);
|
||||
luaL_setmetatable(L, uattackKey);
|
||||
if(weapon != nullptr) {
|
||||
new(L) attack_ref(weapon);
|
||||
luaL_setmetatable(L, uattackKey);
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
}
|
||||
|
||||
static attack_ref& luaW_checkweapon_ref(lua_State* L, int idx)
|
||||
|
|
Loading…
Add table
Reference in a new issue