Monday, 12 August 2013

Lua C API: inserting table elements cause Debug Assertion Failed

Lua C API: inserting table elements cause Debug Assertion Failed

Function returns successfully and I can use values from the table but the
error "Debug Assertion Failed" shows up and it's the end. I know that the
problem with assert is in the for loop but don't exactly know how to fix
that. Thanks in advance.
static int l_xmlNodeGetValues(lua_State * L)
{
int iDocID = luaL_checkint(L, 1);
const char * pszNodeName = luaL_checkstring(L, 2);
CConfig * file = docs.at(iDocID);
int i = 1;
lua_newtable(L);
for( TiXmlElement * e = file->GetRootElement()->FirstChildElement(
pszNodeName ); e; e = e->NextSiblingElement( pszNodeName ) )
{
lua_pushstring(L, e->GetText());
lua_rawseti(L,-2,i);
i++;
}
return 1;
}

No comments:

Post a Comment