fix inventory segfault

Crash in #5437. Inventory actions that changed the name of the item caused the game to crash.