From f79745dae4a9a5fca33320e03a4fc9064b88d01e Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan.bosch@dovecot.fi>
Date: Tue, 12 Mar 2019 03:18:33 +0100
Subject: [PATCH 2/3] submission-login: client-authenticate - Fix crash
 occurring when client disconnects during authentication.

---
 src/submission-login/client-authenticate.c | 3 +++
 src/submission-login/client.c              | 1 +
 2 files changed, 4 insertions(+)

Index: dovecot-2.3.4.1/src/submission-login/client-authenticate.c
===================================================================
--- dovecot-2.3.4.1.orig/src/submission-login/client-authenticate.c	2019-04-29 07:39:05.705254949 -0400
+++ dovecot-2.3.4.1/src/submission-login/client-authenticate.c	2019-04-29 07:39:05.705254949 -0400
@@ -89,6 +89,9 @@ void submission_client_auth_result(struc
 		container_of(client, struct submission_client, common);
 	struct smtp_server_cmd_ctx *cmd = subm_client->pending_auth;
 
+	if (subm_client->conn == NULL)
+		return;
+
 	subm_client->pending_auth = NULL;
 	i_assert(cmd != NULL);
 
Index: dovecot-2.3.4.1/src/submission-login/client.c
===================================================================
--- dovecot-2.3.4.1.orig/src/submission-login/client.c	2019-04-29 07:39:05.705254949 -0400
+++ dovecot-2.3.4.1/src/submission-login/client.c	2019-04-29 07:39:05.705254949 -0400
@@ -176,6 +176,7 @@ static void client_connection_disconnect
 {
 	struct submission_client *client = context;
 
+	client->pending_auth = NULL;
 	client_disconnect(&client->common, reason);
 }
 
