resolve a doublefree problem

valgrind output:

==19831== Invalid free() / delete / delete[] / realloc()
==19831==    at 0x4C2AD3C: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19831==    by 0x410730: maildir_cleanup (drv_maildir.c:166)
==19831==    by 0x410B28: maildir_disown_store (drv_maildir.c:176)
==19831==    by 0x40432A: sync_chans (main.c:652)
==19831==    by 0x406B78: box_closed_p2.part.10 (sync.c:1717)
==19831==    by 0x4119ED: maildir_store_msg (drv_maildir.c:1230)
==19831==    by 0x40C766: done_imap_cmd (drv_imap.c:220)
==19831==    by 0x40F53A: imap_socket_read (drv_imap.c:1063)
==19831==    by 0x40BB95: socket_fd_cb (socket.c:742)
==19831==    by 0x40AE6C: main_loop (util.c:570)
==19831==    by 0x403508: main (main.c:489)
==19831==  Address 0x646ec90 is 0 bytes inside a block of size 24 free'd
==19831==    at 0x4C2AD3C: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19831==    by 0x410730: maildir_cleanup (drv_maildir.c:166)
==19831==    by 0x411A50: maildir_select (drv_maildir.c:901)
==19831==    by 0x408A80: sync_boxes (sync.c:631)
==19831==    by 0x4044BB: sync_chans (main.c:636)
==19831==    by 0x40C766: done_imap_cmd (drv_imap.c:220)
==19831==    by 0x40F53A: imap_socket_read (drv_imap.c:1063)
==19831==    by 0x40BB95: socket_fd_cb (socket.c:742)
==19831==    by 0x40AE6C: main_loop (util.c:570)
==19831==    by 0x403508: main (main.c:489)