Fix bug #611, http://bugs.mariadb.com/show_bug.cgi?id=611
Fixes to Coverity issues 72703, 72713, 72718, 72721