Missing variable initializer in LuaScriptModule
Posted: Sun Apr 12, 2009 04:21
The current implementation of LuaScriptModule has a small bug that breaks error handling in the case where the lua_State object is not owned by the script module.
The d_errFuncIndex variable is not initialized which causes the callback functors to believe they have an error handler set on debug builds when the CRT initializes the heap with 0xCDCDCDCD. You end up with a cryptic "error in error handler" message in the case where the lua script fails.
Current:
Fix:
The d_errFuncIndex variable is not initialized which causes the callback functors to believe they have an error handler set on debug builds when the CRT initializes the heap with 0xCDCDCDCD. You end up with a cryptic "error in error handler" message in the case where the lua script fails.
Current:
Code: Select all
LuaScriptModule::LuaScriptModule(lua_State* state)
{
// just use the given state
d_ownsState = false;
d_state = state;
setModuleIdentifierString();
}
Fix:
Code: Select all
LuaScriptModule::LuaScriptModule(lua_State* state) :
d_errFuncIndex(LUA_NOREF),
d_activeErrFuncIndex(LUA_NOREF)
{
// just use the given state
d_ownsState = false;
d_state = state;
setModuleIdentifierString();
}