From 542e38dd49b4ac0ecf96637be289b6e71ac84990 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 4 Aug 2020 10:10:47 +0200 Subject: [PATCH] fix re-using server connections for new stores we failed to reset the box list pointer after freeing it, which would lead to a crash. we also failed to reset the listing status, which would lead to malfunction if we hadn't already crashed. this inlines imap_cleanup_store(), as there isn't much value in keeping it. the message list is already freed when disowning the store anyway. --- src/drv_imap.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/drv_imap.c b/src/drv_imap.c index d429bcb..fbf3072 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -1558,14 +1558,6 @@ get_cmd_result_p2( imap_store_t *ctx, imap_cmd_t *cmd, int response ) /******************* imap_cancel_store *******************/ - -static void -imap_cleanup_store( imap_store_t *ctx ) -{ - free_generic_messages( ctx->msgs ); - free_string_list( ctx->boxes ); -} - static void imap_cancel_store( store_t *gctx ) { @@ -1581,7 +1573,8 @@ imap_cancel_store( store_t *gctx ) free_list( ctx->ns_other ); free_list( ctx->ns_shared ); free_string_list( ctx->auth_mechs ); - imap_cleanup_store( ctx ); + free_generic_messages( ctx->msgs ); + free_string_list( ctx->boxes ); imap_deref( ctx ); } @@ -1718,7 +1711,9 @@ imap_alloc_store( store_conf_t *conf, const char *label ) for (ctxp = &unowned; (ctx = (imap_store_t *)*ctxp); ctxp = &ctx->gen.next) if (ctx->state != SST_BAD && ((imap_store_conf_t *)ctx->gen.conf)->server == srvc) { *ctxp = ctx->gen.next; - imap_cleanup_store( ctx ); + free_string_list( ctx->boxes ); + ctx->boxes = NULL; + ctx->listed = 0; /* One could ping the server here, but given that the idle timeout * is at least 30 minutes, this sounds pretty pointless. */ ctx->state = SST_HALF;