I had teleported up from lvl 7 of wrong to lvl 6 (trying to end up in the hallway with the sleep fields and the fountain, as I was low on health). When I got there, I didn't immediately recognize the surroundings, so I turned left a few times and was hung. I fired up a debugger and it was in the do/while loop in Location::getReplacementTile() and never met the conditions to exit it. It's possible that I ended up teleporting to a non-walkable tile (I don't know for sure), but I wrote a patch that will work-around the problem and assure that it will at least render grass rather than hang.
The patch also contains some (very) minor cleanups to performance issues (making dirs & dirs_per_step const static assures that compiler will treat them as compile-time constants and promote optimizations).
work-around for hang