Fix clang analyser errors

These problems were found by clang-analyser via "scan-build make"