Page 1 of 1

Missing variable initializer in LuaScriptModule

Posted: Sun Apr 12, 2009 04:21
by Azaril
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:

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();
}

Posted: Sun Apr 12, 2009 11:00
by CrazyEddie
Hi, welcome, and thanks for the report + fix :)

I should hopefully get around to committing it to svn branches/v0-6 later today (and merge into head soon).

CE.