]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: server: command: Prevent reference counting from within destroy hook.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Wed, 31 Oct 2018 23:27:50 +0000 (00:27 +0100)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 12 Feb 2019 13:41:49 +0000 (15:41 +0200)
src/lib-smtp/smtp-server-command.c
src/lib-smtp/smtp-server-private.h

index 1c0e526e463458c363ba7885bc2d9c44b602df05..c673ebc245e75a09a59e036881b8e8bf8eaf2d65 100644 (file)
@@ -243,6 +243,8 @@ smtp_server_command_new(struct smtp_server_connection *conn,
 
 void smtp_server_command_ref(struct smtp_server_command *cmd)
 {
+       if (cmd->destroying)
+               return;
        cmd->refcount++;
 }
 
@@ -253,9 +255,13 @@ bool smtp_server_command_unref(struct smtp_server_command **_cmd)
 
        *_cmd = NULL;
 
+       if (cmd->destroying)
+               return FALSE;
+
        i_assert(cmd->refcount > 0);
        if (--cmd->refcount > 0)
                return TRUE;
+       cmd->destroying = TRUE;
 
        smtp_server_command_debug(&cmd->context, "Destroy");
 
index 3b0c397241fd153a694963db12337e49b2955b72..9d9365880b420a0bef50d569e9ad92b5c5d559c6 100644 (file)
@@ -108,6 +108,7 @@ struct smtp_server_command {
        bool input_locked:1;
        bool input_captured:1;
        bool reply_early:1;
+       bool destroying:1;
 };
 
 struct smtp_server_recipient_private {