Fix bugs identified by scan-build.