Fix a number of clang analyzer false-positives

Most of these are in somewhat non-obvious code where it is probably
a good idea to initialize variables and add extra assertions anyway.

Closes 13036.  Patches from "teor".
Merge remote-tracking branch 'origin/maint-0.2.5'