Fix a couple of bugs picked up by clang static analyser.