Random crash on access to my std::list<string> object
<p>I have been getting random crashes when trying to access my <code>std::list<code>&lt;string&gt;</code></code> object and can't figure out why it happens.</p>

<p>I started out with an extern <code>vector<code>&lt;string&gt;</code></code> object but I've created a class for accessing it now, use a list instead (not that it matters but probably more appropriate for what I need it for) and make use of critical section just to be sure, however it didn't help any.</p>

<p>When I was using a vector I had crashes when calling size().
Using critical section or not has the same effect.
I am hoping someone can point me in the right direction.</p>

<p>Thank you!
The code:
<pre><code>
class CWordHandler
{
public:
 void AddWord(string text);
 void DeleteWord(unsigned index);
 string ReadWord(unsigned index);
 void ClearWords();
 unsigned GetSize();</p>

<p>private:
 list<code>&lt;string&gt;</code> WordContainer;
};
extern CWordHandler WordHandler;
// ----------------------------------
string CWordHandler::ReadWord(unsigned index)
{
 list<code>&lt;string&gt;</code>::iterator it = WordContainer.begin(); // crash
 advance(it, index);
 return index >= 0 &amp;&amp; index &lt;= WordContainer.size() ? *it : 0;
}</pre></code></p>
