imap: Fixed memory leak following commit f6010d9a0359