Fixes for Coverity-identified issues.

Signed-off-by: James Hunt <james.hunt@ubuntu.com>