aboutsummaryrefslogtreecommitdiff
path: root/src/script/common/c_content.cpp
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-02-12 20:42:19 +0100
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-02-12 20:42:19 +0100
commitd3780cefd10472a57425cf5e0ab4cf4b816401be (patch)
treea76dd2e141a69cfd7537a8c9dfe340711198c402 /src/script/common/c_content.cpp
parentd1c84ada2b3b525634690785a8f8cda0f0252782 (diff)
downloaddragonfireclient-d3780cefd10472a57425cf5e0ab4cf4b816401be.tar.xz
Attempt to fix SEGFAULT in push_inventory
Diffstat (limited to 'src/script/common/c_content.cpp')
-rw-r--r--src/script/common/c_content.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index e9090e733..f3896a28b 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -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");