My suspicion:
In #1386, an item type cache was added, but from what I can tell, it assumes an item will keep its type forever.
item::convert changes the type of an item, but doesn't change its location in the inventory, so it might try to do something on an empty list.
For example, line inventory.cpp::429
other = items.erase( other, iter->front().typeId() );
If iter->front().typeId() doesn't point to a list containing other, the return value of erase will be return std::list<std::list<item> >::erase( stack_iter );.
So other probably becomes this new iterator, which seems to be an iterator to a temporary element.
There really, really should be at least a debugmsg for this case.
Describe the bug
Activating multiple grenades in a row will crash the game.
Steps To Reproduce
Expected behavior
Crashes are obviously unacceptable.
Screenshots
Versions and configuration
Reproduces both on Windows releases and git-compiled versions.
Additional context
Relevant parts of crash log/stacktrace:
My suspicion: In #1386, an item type cache was added, but from what I can tell, it assumes an item will keep its type forever.
item::convert
changes the type of an item, but doesn't change its location in the inventory, so it might try to do something on an empty list. For example, lineinventory.cpp::429
If
iter->front().typeId()
doesn't point to a list containingother
, the return value oferase
will bereturn std::list<std::list<item> >::erase( stack_iter );
. Soother
probably becomes this new iterator, which seems to be an iterator to a temporary element. There really, really should be at least a debugmsg for this case.