Better handling of size limit when resizing a table
Avoid silent conversions from int to unsigned int when calling 'luaH_resize'; avoid silent conversions from lua_Integer to int in 'table.create'; MAXASIZE corrected for the new implementation of arrays; 'luaH_resize' checks explicitly whether new size respects MAXASIZE. (Even constructors were bypassing that check.)
This commit is contained in:
@@ -59,8 +59,10 @@ static void checktab (lua_State *L, int arg, int what) {
|
||||
|
||||
|
||||
static int tcreate (lua_State *L) {
|
||||
int sizeseq = (int)luaL_checkinteger(L, 1);
|
||||
int sizerest = (int)luaL_optinteger(L, 2, 0);
|
||||
lua_Unsigned sizeseq = (lua_Unsigned)luaL_checkinteger(L, 1);
|
||||
lua_Unsigned sizerest = (lua_Unsigned)luaL_optinteger(L, 2, 0);
|
||||
luaL_argcheck(L, sizeseq <= UINT_MAX, 1, "out of range");
|
||||
luaL_argcheck(L, sizerest <= UINT_MAX, 2, "out of range");
|
||||
lua_createtable(L, sizeseq, sizerest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user