Fixed crash when attempting to access nonexistant inventory from Lua API

master
Elias Fleckenstein 2020-11-28 12:08:53 +01:00
parent a65251a7a8
commit 8de51dae97
1 changed files with 2 additions and 0 deletions

View File

@ -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);