diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-06-21 19:42:06 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-06-21 19:42:06 +0000 |
commit | e79638b70be57501bb9995b24665a109188922fc (patch) | |
tree | 9482f9a9fcd5a461a6b9cf1b9742b3bc0df505bb /plugins/MirLua/src/lua/ltablib.c | |
parent | 8ba0d63234b84060efe27542bf317cb9cf50b3af (diff) |
MirLua: lua updated to 5.3.1
git-svn-id: http://svn.miranda-ng.org/main/trunk@14308 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/lua/ltablib.c')
-rw-r--r-- | plugins/MirLua/src/lua/ltablib.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/MirLua/src/lua/ltablib.c b/plugins/MirLua/src/lua/ltablib.c index 8f78afb7f2..a05c885c03 100644 --- a/plugins/MirLua/src/lua/ltablib.c +++ b/plugins/MirLua/src/lua/ltablib.c @@ -1,5 +1,5 @@ /* -** $Id: ltablib.c,v 1.79 2014/11/02 19:19:04 roberto Exp $ +** $Id: ltablib.c,v 1.80 2015/01/13 16:27:29 roberto Exp $ ** Library for Table Manipulation ** See Copyright Notice in lua.h */ @@ -124,8 +124,6 @@ static int tmove (lua_State *L) { lua_Integer e = luaL_checkinteger(L, 3); lua_Integer t = luaL_checkinteger(L, 4); int tt = !lua_isnoneornil(L, 5) ? 5 : 1; /* destination table */ - /* the following restriction avoids several problems with overflows */ - luaL_argcheck(L, f > 0, 2, "initial position must be positive"); if (e >= f) { /* otherwise, nothing to move */ lua_Integer n, i; ta.geti = (luaL_getmetafield(L, 1, "__index") == LUA_TNIL) @@ -134,7 +132,11 @@ static int tmove (lua_State *L) { ta.seti = (luaL_getmetafield(L, tt, "__newindex") == LUA_TNIL) ? (luaL_checktype(L, tt, LUA_TTABLE), lua_rawseti) : lua_seti; + luaL_argcheck(L, f > 0 || e < LUA_MAXINTEGER + f, 3, + "too many elements to move"); n = e - f + 1; /* number of elements to move */ + luaL_argcheck(L, t <= LUA_MAXINTEGER - n + 1, 4, + "destination wrap around"); if (t > f) { for (i = n - 1; i >= 0; i--) { (*ta.geti)(L, 1, f + i); |