Skip to content

Commit

Permalink
imapc: Fix potential crash if initial sync fails.
Browse files Browse the repository at this point in the history
Happened at least if mailbox had 0 mails and a failing mailbox_sync() was
called twice.

Fixes:
Panic: file imapc-sync.c: line 477 (imapc_sync_index): assertion failed: (mbox->sync_fetch_first_uid == 1)
  • Loading branch information
sirainen committed Jun 8, 2017
1 parent e106213 commit d8ed8d5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib-storage/index/imapc/imapc-sync.c
Expand Up @@ -483,7 +483,6 @@ static void imapc_sync_index(struct imapc_sync_context *ctx)
adding new messages requires sync locking to avoid
duplicates. */
imapc_sync_send_commands(ctx, mbox->sync_fetch_first_uid);
mbox->sync_fetch_first_uid = 0;
}

imapc_sync_expunge_finish(ctx);
Expand All @@ -500,6 +499,10 @@ static void imapc_sync_index(struct imapc_sync_context *ctx)
if (mbox->box.v.sync_notify != NULL)
mbox->box.v.sync_notify(&mbox->box, 0, 0);

if (!ctx->failed) {
/* reset only after a successful sync */
mbox->sync_fetch_first_uid = 0;
}
if (!mbox->initial_sync_done && !ctx->failed) {
imapc_initial_sync_check(ctx, FALSE);
mbox->initial_sync_done = TRUE;
Expand Down

0 comments on commit d8ed8d5

Please sign in to comment.