13
0

Lua Array, assert indices > 0

This commit is contained in:
Robin Gareus 2020-02-02 20:57:47 +01:00
parent fbacb13d2d
commit 34c4602e61
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -1050,6 +1050,7 @@ struct CFunc
static int array_index (lua_State* L) {
T** parray = (T**) luaL_checkudata (L, 1, typeid(T).name());
int const index = luabridge::Stack<int>::get (L, 2);
assert (index > 0);
luabridge::Stack<T>::push (L, (*parray)[index-1]);
return 1;
}
@ -1060,6 +1061,7 @@ struct CFunc
T** parray = (T**) luaL_checkudata (L, 1, typeid(T).name());
int const index = luabridge::Stack<int>::get (L, 2);
T const value = luabridge::Stack<T>::get (L, 3);
assert (index > 0);
(*parray)[index-1] = value;
return 0;
}