File 0008-lib-smtp-smtp-server-command-Guarantee-that-non-dest.patch of Package dovecot23.16062

From 2b4f1e47a4ca8a192bf3f7e944c0ad07b21b2ed1 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan.bosch@open-xchange.com>
Date: Tue, 24 Mar 2020 12:13:43 +0100
Subject: [PATCH 08/16] lib-smtp: smtp-server-command - Guarantee that
 non-destroy hooks aren't called for an ended command.

---
 src/lib-smtp/smtp-server-command.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/lib-smtp/smtp-server-command.c b/src/lib-smtp/smtp-server-command.c
index ac25933a64..a4d0bc70b6 100644
--- a/src/lib-smtp/smtp-server-command.c
+++ b/src/lib-smtp/smtp-server-command.c
@@ -389,8 +389,11 @@ bool smtp_server_command_call_hooks(struct smtp_server_command **_cmd,
 	struct smtp_server_command *cmd = *_cmd;
 	struct smtp_server_command_hook *hook;
 
-	if (type != SMTP_SERVER_COMMAND_HOOK_DESTROY)
+	if (type != SMTP_SERVER_COMMAND_HOOK_DESTROY) {
+		if (cmd->state >= SMTP_SERVER_COMMAND_STATE_FINISHED)
+			return FALSE;
 		smtp_server_command_ref(cmd);
+	}
 
 	hook = cmd->hooks_head;
 	while (hook != NULL) {
-- 
2.11.0

openSUSE Build Service is sponsored by