mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Lua API: fix OOB array access in find_nodes_near (#14948)
This commit is contained in:
parent
f04cdc00a6
commit
e236ad8348
1 changed files with 3 additions and 3 deletions
|
@ -970,8 +970,8 @@ int ModApiEnvBase::findNodesInArea(lua_State *L, const NodeDefManager *ndef,
|
||||||
});
|
});
|
||||||
|
|
||||||
// last filter table is at top of stack
|
// last filter table is at top of stack
|
||||||
u32 i = filter.size() - 1;
|
u32 i = filter.size();
|
||||||
do {
|
while (i --> 0) {
|
||||||
if (idx[i] == 0) {
|
if (idx[i] == 0) {
|
||||||
// No such node found -> drop the empty table
|
// No such node found -> drop the empty table
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
@ -979,7 +979,7 @@ int ModApiEnvBase::findNodesInArea(lua_State *L, const NodeDefManager *ndef,
|
||||||
// This node was found -> put table into the return table
|
// This node was found -> put table into the return table
|
||||||
lua_setfield(L, base, ndef->get(filter[i]).name.c_str());
|
lua_setfield(L, base, ndef->get(filter[i]).name.c_str());
|
||||||
}
|
}
|
||||||
} while (i-- != 0);
|
}
|
||||||
|
|
||||||
assert(lua_gettop(L) == base);
|
assert(lua_gettop(L) == base);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue