]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Attempt to fix SEGFAULT in push_inventory
authorElias Fleckenstein <eliasfleckenstein@web.de>
Fri, 12 Feb 2021 19:42:19 +0000 (20:42 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Fri, 12 Feb 2021 19:42:19 +0000 (20:42 +0100)
src/script/common/c_content.cpp

index e9090e73368ef35bdb0f53c7f0bfc61627f472ff..f3896a28bf903e2ab3bfe286bb9790c4a4bdcf11 100644 (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");