Fixing a few cases of undefined behaviour introduced by recent
formatter work.

Thanks, Coverity!