More issues reported by Coverity

Included one regression caused by a previous patch.