Fix issues found by Coverity Scan in run 224 (22 Sep)

See branches cov_run244 for merge to master, and cov_run244_022 for merge to maint-0.2.2.

The remaining issues in run 224 seem harmless or false-positivish.