BUG:374524 Fix a possible crash in the undo stack
This is the only thing that could account for that stacktrace, but since the crash is not reproducible, I just have to guess...