Missing variable initializer in LuaScriptModule

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

Azaril
Just popping in
Just popping in
Posts: 1
Joined: Sun Apr 12, 2009 04:14

Missing variable initializer in LuaScriptModule

Postby Azaril » 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:

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

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Sun Apr 12, 2009 11:00

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.


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 0 guests