staticvoidtest(lua_State *L) {
lua_pushnil(L); //simulate an exception where a table is expected herelua_pushstring(L,"abcd");
lua_rawget(L,-2);
}
If call this function with lua_pcall, the program directly crashes. And if change lua_rawget as lua_gettable, the program correctly catches the error attempt to index a nil value. The same issue happens on lua_rawset.
My OS is Win10 and LuaJIT is up to date, is this behaviour expected? Thanks.
The text was updated successfully, but these errors were encountered:
hyee
changed the title
lua_rawset / lua_rawset is not catched by lua_pcalllua_rawget / lua_rawset is not catched by lua_pcallFeb 17, 2022
First, the behavior is the same with Lua, so the question does not belong here.
The Lua/C API is a low-level API. It assumes certain arguments on the stack to be of the correct type. You can enable API checks in the Makefile to catch (some) of this API misuse in your programs.
With below function
If call this function with
lua_pcall, the program directly crashes. And if changelua_rawgetaslua_gettable, the program correctly catches the errorattempt to index a nil value. The same issue happens onlua_rawset.My OS is Win10 and LuaJIT is up to date, is this behaviour expected? Thanks.
The text was updated successfully, but these errors were encountered: