Attempt to fix SEGFAULT in push_inventory

wsc-dfc
Elias Fleckenstein 2021-02-12 20:42:19 +01:00
parent d1c84ada2b
commit d3780cefd1
1 changed files with 4 additions and 2 deletions

View File

@ -1313,6 +1313,8 @@ void push_tool_capabilities(lua_State *L,
/******************************************************************************/
void push_inventory(lua_State *L, Inventory *inventory)
{
if (! inventory)
throw SerializationError("Attempt to push nonexistant inventory");
std::vector<const InventoryList*> lists = inventory->getLists();
std::vector<const InventoryList*>::iterator iter = lists.begin();
lua_createtable(L, 0, lists.size());
@ -1869,7 +1871,7 @@ void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm,
} else {
push_objectRef(L, pointed.object_id);
}
lua_setfield(L, -2, "ref");
} else {
lua_pushstring(L, "nothing");
@ -2129,7 +2131,7 @@ void push_collision_move_result(lua_State *L, const collisionMoveResult &res)
void push_physics_override(lua_State *L, float speed, float jump, float gravity, bool sneak, bool sneak_glitch, bool new_move)
{
lua_createtable(L, 0, 6);
lua_pushnumber(L, speed);
lua_setfield(L, -2, "speed");