Fix defects found by Coverity <https://info.ravenbrook.com/mail/2014/06/13/18-12-37/0/>