When I run my application in debug mode, sometimes I get a runtime error in this function:
void ChatListHandler::seatOccupancyChanged( const std::string& userName, bool occupied, bool isSelf, bool isSelfTable, int tableNo, int seatNo, int numPlayersAtTable )
{
if(!isSelf && (isInGroup(userName,IN_GAME_GROUP) || isInGroup(userName,IN_LOBBY_GROUP)))
{
if(occupied)
{
movePlayer(userName,IN_GAME_GROUP);
}
else
{
movePlayer(userName,IN_LOBBY_GROUP);
}
}
}
bool ChatListHandler::isInGroup( const std::string& name, GroupTypeEnum group )
{
for(size_t i = 0; i < m_groups.size(); ++i)
{
if(m_groups[i].second == group)
{
if(m_groups[i].first->getList())
{
for(agui::ListItem::iterator it =
m_groups[i].first->getList()->getItemsBegin(); it !=
m_groups[i].first->getList()->getItemsEnd(); ++it)
{
if((*it).first.text == name)
{
return true;
}
}
}
break;
}
}
return false;
m_list->repositionGroups();
}
It crashes on:
if((*it).first.text == name)
I get:
Unhandled exception at 0x5fd1942c (msvcp90d.dll) in my.exe: 0xC0000005: Access violation reading location 0x00000040.
The call stack looks like:

Thanks
I can’t be sure without seeing all the code, but my guess is that there error has to do with these lines:
Unless your call to
getList()is always returning exactly the same list every time (that is, a pointer to the same list, not a copy), you could be getting iterators over different lists. This would mean that the checkit != m_groups[i].first->getList()->getItemsEnd()would always befalse, since the iterators come from different lists. In that case, your iterator could walk off the end of the list, so the dereference would cause a crash.Hope this helps!