|
|
@ -733,8 +733,18 @@ static int lookup_container_field(lua_State *state, int field, const char *mode
|
|
|
|
* Index verification: number and in range.
|
|
|
|
* Index verification: number and in range.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static int check_container_index(lua_State *state, int len,
|
|
|
|
static int check_container_index(lua_State *state, int len,
|
|
|
|
int fidx, int iidx, const char *mode)
|
|
|
|
int fidx, int iidx, const char *mode,
|
|
|
|
|
|
|
|
bool is_insert = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (is_insert && len >= 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (lua_type(state, iidx) == LUA_TSTRING
|
|
|
|
|
|
|
|
&& strcmp(lua_tostring(state, iidx), "#") == 0)
|
|
|
|
|
|
|
|
return len;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
len++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!lua_isnumber(state, iidx))
|
|
|
|
if (!lua_isnumber(state, iidx))
|
|
|
|
field_error(state, fidx, "invalid index", mode);
|
|
|
|
field_error(state, fidx, "invalid index", mode);
|
|
|
|
|
|
|
|
|
|
|
@ -867,8 +877,7 @@ static int method_container_insert(lua_State *state)
|
|
|
|
|
|
|
|
|
|
|
|
auto id = (container_identity*)lua_touserdata(state, UPVAL_CONTAINER_ID);
|
|
|
|
auto id = (container_identity*)lua_touserdata(state, UPVAL_CONTAINER_ID);
|
|
|
|
int len = id->lua_item_count(state, ptr, container_identity::COUNT_LEN);
|
|
|
|
int len = id->lua_item_count(state, ptr, container_identity::COUNT_LEN);
|
|
|
|
if (len >= 0) len++;
|
|
|
|
int idx = check_container_index(state, len, UPVAL_METHOD_NAME, 2, "call", true);
|
|
|
|
int idx = check_container_index(state, len, UPVAL_METHOD_NAME, 2, "call");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!id->lua_insert(state, UPVAL_METHOD_NAME, ptr, idx, 3))
|
|
|
|
if (!id->lua_insert(state, UPVAL_METHOD_NAME, ptr, idx, 3))
|
|
|
|
field_error(state, UPVAL_METHOD_NAME, "not supported", "call");
|
|
|
|
field_error(state, UPVAL_METHOD_NAME, "not supported", "call");
|
|
|
|