Merge pull request #1128 from jboeuf/static_analysis_fixes

Fixing errors found by clang static analysis.