From 34c4602e61b61f6e7795d02bd64b477c9f26cfd7 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 2 Feb 2020 20:57:47 +0100 Subject: [PATCH] Lua Array, assert indices > 0 --- libs/lua/LuaBridge/detail/CFunctions.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/lua/LuaBridge/detail/CFunctions.h b/libs/lua/LuaBridge/detail/CFunctions.h index 88c30fc4ad..9a14c0892f 100644 --- a/libs/lua/LuaBridge/detail/CFunctions.h +++ b/libs/lua/LuaBridge/detail/CFunctions.h @@ -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::get (L, 2); + assert (index > 0); luabridge::Stack::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::get (L, 2); T const value = luabridge::Stack::get (L, 3); + assert (index > 0); (*parray)[index-1] = value; return 0; }