commit 5e5c7fb50866be4a744642c225205039bb306b88
parent 1225f0b86b7b7bdab3d4c9a03d3198ff90b0925a
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date: Sun, 19 Jun 2022 11:19:34 +0200
free IMAP command's payload prior to invoking its completion callback
otherwise the synching may livelock due to failing to schedule follow-up
commands, thinking the buffers are still full. of course, this is
relevant only for commands that failed early and thus didn't free the
payload right after submission already - which will be possible only
after the next commit.
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/drv_imap.c b/src/drv_imap.c
@@ -288,11 +288,13 @@ done_imap_cmd( imap_store_t *ctx, imap_cmd_t *cmd, int response )
{
if (cmd->param.wait_check)
ctx->num_wait_check--;
- cmd->param.done( ctx, cmd, response );
if (cmd->param.data) {
free( cmd->param.data );
+ cmd->param.data = NULL;
+ // This needs to happen before calling back.
ctx->buffer_mem -= cmd->param.data_len;
}
+ cmd->param.done( ctx, cmd, response );
free( cmd->cmd );
free( cmd );
}