fix(api): check type in nlua_pop_keydict (#15940)

This commit is contained in:
virchau13
2021-10-08 12:31:24 +08:00
parent 7f93b2ab01
commit 6064376f6d
2 changed files with 10 additions and 0 deletions

View File

@@ -1303,6 +1303,12 @@ void nlua_init_types(lua_State *const lstate)
void nlua_pop_keydict(lua_State *L, void *retval, field_hash hashy, Error *err)
{
if (!lua_istable(L, -1)) {
api_set_error(err, kErrorTypeValidation, "Expected lua table");
lua_pop(L, -1);
return;
}
lua_pushnil(L); // [dict, nil]
while (lua_next(L, -2)) {
// [dict, key, value]