Minor bugs found with static analysis

I'm testing a static analysis tool, here are some of its findings.