1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-25 17:53:47 +00:00

fix possible out of bounds access

This commit is contained in:
fgenesis 2022-11-23 20:42:30 +01:00
parent ed98a3328e
commit 9583375537

View file

@ -7101,7 +7101,7 @@ luaFunc(esetv)
Entity *e = entity(L); Entity *e = entity(L);
EV ev = (EV)lua_tointeger(L, 2); EV ev = (EV)lua_tointeger(L, 2);
int n = lua_tointeger(L, 3); int n = lua_tointeger(L, 3);
if (e) if (e && ev < EV_MAX)
e->setv(ev, n); e->setv(ev, n);
luaReturnNum(n); luaReturnNum(n);
} }
@ -7111,7 +7111,7 @@ luaFunc(egetv)
Entity *e = entity(L); Entity *e = entity(L);
EV ev = (EV)lua_tointeger(L, 2); EV ev = (EV)lua_tointeger(L, 2);
int v = 0; int v = 0;
if (e) if (e && ev < EV_MAX)
v = e->getv(ev); v = e->getv(ev);
luaReturnNum(v); luaReturnNum(v);
} }
@ -7121,7 +7121,7 @@ luaFunc(esetvf)
Entity *e = entity(L); Entity *e = entity(L);
EV ev = (EV)lua_tointeger(L, 2); EV ev = (EV)lua_tointeger(L, 2);
float n = lua_tonumber(L, 3); float n = lua_tonumber(L, 3);
if (e) if (e && ev < EV_MAX)
e->setvf(ev, n); e->setvf(ev, n);
luaReturnNum(n); luaReturnNum(n);
} }
@ -7129,12 +7129,10 @@ luaFunc(esetvf)
luaFunc(egetvf) luaFunc(egetvf)
{ {
Entity *e = entity(L); Entity *e = entity(L);
EV ev = (EV)lua_tointeger(L, 2);
float vf = 0; float vf = 0;
if (e) if (e && ev < EV_MAX)
{
EV ev = (EV)lua_tointeger(L, 2);
vf = e->getvf(ev); vf = e->getvf(ev);
}
luaReturnNum(vf); luaReturnNum(vf);
} }
@ -7143,9 +7141,7 @@ luaFunc(eisv)
Entity *e = entity(L); Entity *e = entity(L);
EV ev = (EV)lua_tointeger(L, 2); EV ev = (EV)lua_tointeger(L, 2);
int n = lua_tointeger(L, 3); int n = lua_tointeger(L, 3);
bool b = 0; bool b = e && ev < EV_MAX && e->isv(ev, n);
if (e)
b = e->isv(ev, n);
luaReturnBool(b); luaReturnBool(b);
} }