Scanbuild

Some bugs found with Scanbuild