Fix coverity issues

Hi Nicolas,
I ran Coverity on the branch you previously pulled from me (better later than never ;-) ) it found a couple of issues. This branch fixes those, not sure if the CID numbers mean anything to anybody (I am not familiar enough with Coverity to see where those get published if at all). Let me know if the format of the patch is good for you, e.g. I am quite happy to squash these into a single commit, or remove the CID numbers or.... basically whatever suits you I am happy to do