CleverRaven/Cataclysm-DDA — pull request #8187 by BevapDin (2014-07-09 00:35:40+00:00)
Title: Fix iterator related crashes

This might fix some crashes:

I added `-D_GLIBCXX_DEBUG` to the compiler options to catch those invalid iterators. It actually complains about the iterator in `Creature::remove_effect`.

`Creature::remove_effect` (called from inside the loop in `Creature::process_effects`) invalidate the iterator there. But the iterator is used after the removal in the increment `++it`. That accesses an invalid iterator.

There was some wrong iterator in Item_factory, which I fixed (and the warning there, too).

While testing I found another buggy iterator in fields.cpp. When an item with content is removed from the map (because it has been completely burned), its contents are added to the map. Adding contents to the items-vector can invalidate it (if it was reallocated), which in turn makes the reference to the burned item and its contents invalid.

Maybe the items on the map should really be stored in a `std::list` but that involves lots of code changes all over the place.