]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Added assert to make sure client_command_context isn't freed too early.
authorTimo Sirainen <tss@iki.fi>
Wed, 9 Dec 2015 10:43:18 +0000 (12:43 +0200)
committerTimo Sirainen <tss@iki.fi>
Wed, 9 Dec 2015 10:43:18 +0000 (12:43 +0200)
src/imap/imap-client.c
src/imap/imap-client.h
src/imap/imap-commands.c

index 393463447589f05c8142a0775eb252e0f1b33fe3..07cacd466920a80bb2e10605e4cead242971a552 100644 (file)
@@ -748,6 +748,7 @@ void client_command_free(struct client_command_context **_cmd)
 
        *_cmd = NULL;
 
+       i_assert(!cmd->executing);
        i_assert(client->output_cmd_lock == NULL);
 
        /* reset input idle time because command output might have taken a
index 1a7a2e6ea49d4c6f0b570b48246805680e1667b1..36271de26b57a87e8eb7b8b44c394ab8a686f0ae 100644 (file)
@@ -93,6 +93,7 @@ struct client_command_context {
        unsigned int search_save_result_used:1; /* command uses search save */
        unsigned int temp_executed:1; /* temporary execution state tracking */
        unsigned int tagline_sent:1;
+       unsigned int executing:1;
 };
 
 struct imap_client_vfuncs {
index 9c5f271c1a867a22f2083ba99343987376499fe9..67221ad80b012cc279602a5fc4e65be5b2e8c809 100644 (file)
@@ -159,16 +159,20 @@ bool command_exec(struct client_command_context *cmd)
        struct timeval cmd_start_timeval;
        uint64_t cmd_start_bytes_in, cmd_start_bytes_out;
 
+       i_assert(!cmd->executing);
+
        io_loop_time_refresh();
        cmd_start_timeval = ioloop_timeval;
        cmd_start_bytes_in = i_stream_get_absolute_offset(cmd->client->input);
        cmd_start_bytes_out = cmd->client->output->offset;
 
+       cmd->executing = TRUE;
        array_foreach(&command_hooks, hook)
                hook->pre(cmd);
        finished = cmd->func(cmd);
        array_foreach(&command_hooks, hook)
                hook->post(cmd);
+       cmd->executing = FALSE;
        if (cmd->state == CLIENT_COMMAND_STATE_DONE)
                finished = TRUE;