Fix potential errors identified using clang-analyzer

To build with clang-analyzer need to run both configure and make
using scan-build, ie:

scan-build ./configure --prefix=/usr --libdir=/usr/lib64 --enable-debug
scan-build make