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.
This commit is contained in:
Oswald Buddenhagen 2020-08-04 10:10:47 +02:00
parent c82397cf6e
commit 542e38dd49

View File

@ -1558,14 +1558,6 @@ get_cmd_result_p2( imap_store_t *ctx, imap_cmd_t *cmd, int response )
/******************* imap_cancel_store *******************/ /******************* imap_cancel_store *******************/
static void
imap_cleanup_store( imap_store_t *ctx )
{
free_generic_messages( ctx->msgs );
free_string_list( ctx->boxes );
}
static void static void
imap_cancel_store( store_t *gctx ) 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_other );
free_list( ctx->ns_shared ); free_list( ctx->ns_shared );
free_string_list( ctx->auth_mechs ); free_string_list( ctx->auth_mechs );
imap_cleanup_store( ctx ); free_generic_messages( ctx->msgs );
free_string_list( ctx->boxes );
imap_deref( ctx ); 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) 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) { if (ctx->state != SST_BAD && ((imap_store_conf_t *)ctx->gen.conf)->server == srvc) {
*ctxp = ctx->gen.next; *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 /* One could ping the server here, but given that the idle timeout
* is at least 30 minutes, this sounds pretty pointless. */ * is at least 30 minutes, this sounds pretty pointless. */
ctx->state = SST_HALF; ctx->state = SST_HALF;