This is the culprit code, all the Entities in mList is created with new, but for some reason it crashes at the Update() function in the above code. This doesnt happen if i comment out the delete and just erase the pointer from the array, but this obviously means memory-leaking. Entity is the base class for a bunch of other classes that reaches this piece of code, not sure if that means anything?Code:for(std::vector<Entity*>::iterator TempIterator = mList.begin(); TempIterator != mList.end();) { (*TempIterator)->Update(); if((*TempIterator)->IsDead()) { delete (*TempIterator); TempIterator = mList.erase(TempIterator); } else TempIterator++; }
I'm stuck, can you guys spot anything suspicious in the code above? If not then atleast i will know the problem is somewhere else.