From c4f4058d16096f23eea0b3182205d6653f5954dd Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 10 Feb 2021 13:13:34 +0200 Subject: [PATCH] imap: NOTIFY - Fix crash if client disconnects while sending FETCH notification Fixes: Panic: Trying to close mailbox INBOX with open transactions --- src/imap/imap-notify.c | 6 +++--- src/imap/imap-sync.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/imap/imap-notify.c b/src/imap/imap-notify.c index 481caad6e0..ca6303adc7 100644 --- a/src/imap/imap-notify.c +++ b/src/imap/imap-notify.c @@ -273,12 +273,12 @@ imap_client_notify_selected(struct client *client) if (!fetch_ctx->state.fetching) return 1; - if ((ret = imap_fetch_more_no_lock_update(fetch_ctx)) <= 0) - return ret; + if ((ret = imap_fetch_more_no_lock_update(fetch_ctx)) == 0) + return 0; /* finished the FETCH */ if (imap_fetch_end(fetch_ctx) < 0) return -1; - return 1; + return ret; } static int imap_client_notify_more(struct client *client) diff --git a/src/imap/imap-sync.c b/src/imap/imap-sync.c index 2a6b02d3a7..13b6101787 100644 --- a/src/imap/imap-sync.c +++ b/src/imap/imap-sync.c @@ -42,12 +42,12 @@ static int search_update_fetch_more(const struct imap_search_update *update) { int ret; - if ((ret = imap_fetch_more_no_lock_update(update->fetch_ctx)) <= 0) - return ret; + if ((ret = imap_fetch_more_no_lock_update(update->fetch_ctx)) == 0) + return 0; /* finished the FETCH */ if (imap_fetch_end(update->fetch_ctx) < 0) return -1; - return 1; + return ret; } static int -- 2.47.3