]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lmtp: lmtp-client - Fix potential segfault occurring at service termination
authorStephan Bosch <stephan.bosch@open-xchange.com>
Sun, 21 Jan 2024 16:48:07 +0000 (17:48 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 22 Jan 2024 19:02:32 +0000 (19:02 +0000)
Invalid write of size 8 found by Valgrind.
Broken by 9a1a1cc222d7b67abf3ff621b70ed92b1b6d8d39.

src/lmtp/lmtp-client.c

index 3ac84737b371db55ff2ecfa7682f42d2a191d20b..a7669d20c2c8a3cbad79179610f32f8ee5e98367 100644 (file)
@@ -270,12 +270,14 @@ void client_destroy(struct client **_client, const char *enh_code,
 
        *_client = NULL;
 
+       client_ref(client);
        smtp_server_connection_terminate(&conn,
                (enh_code == NULL ? "4.0.0" : enh_code), reason);
        /* smtp_server_connection_terminate() calls
           client_connection_state_changed(), which may still access
           client->conn. Don't clear it before that. */
        client->conn = NULL;
+       client_unref(&client);
 }
 
 static void