From 8de51dae97aa2fe6ea02e4cf437bfe2b2a38eb06 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 28 Nov 2020 12:08:53 +0100 Subject: Fixed crash when attempting to access nonexistant inventory from Lua API --- src/script/lua_api/l_client.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/script/lua_api/l_client.cpp') diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index 6c4878873..5e69d55dd 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -471,6 +471,8 @@ int ModApiClient::l_get_inventory(lua_State *L) try { inventory_location.deSerialize(location); inventory = client->getInventory(inventory_location); + if (! inventory) + throw SerializationError(std::string("Attempt to access nonexistant inventory (") + location + ")"); push_inventory(L, inventory); } catch (SerializationError &) { lua_pushnil(L); -- cgit v1.2.3