Fix some errors reported by clang static analyzer.