mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-21 18:11:11 +00:00
Increase safety checks around ObjectRefs
This commit is contained in:
parent
41091a147c
commit
c8dc9c2b8d
6 changed files with 27 additions and 12 deletions
|
@ -2236,12 +2236,14 @@ void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm,
|
|||
|
||||
void push_objectRef(lua_State *L, const u16 id)
|
||||
{
|
||||
assert(id != 0);
|
||||
// Get core.object_refs[i]
|
||||
lua_getglobal(L, "core");
|
||||
lua_getfield(L, -1, "object_refs");
|
||||
luaL_checktype(L, -1, LUA_TTABLE);
|
||||
lua_pushinteger(L, id);
|
||||
lua_gettable(L, -2);
|
||||
assert(!lua_isnoneornil(L, -1));
|
||||
lua_remove(L, -2); // object_refs
|
||||
lua_remove(L, -2); // core
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue