Fix Clang Static Analyzer warnings

Some fixes to error code paths.