fix bugs revealed by llvm static analyzer