]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap-login: Fix accessing freed memory when using IMAP COMPRESS
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 3 Feb 2025 10:21:37 +0000 (12:21 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:16 +0000 (12:34 +0200)
Broken by "imap-login: Fix leaking settings instance memory" commit.

src/imap-login/imap-login-client.c

index 90bc70127c1d7ab315b9b3fcb8d34ec400e5effe..a31be22fc3710880e81f87603007207c6f7154d9 100644 (file)
@@ -419,8 +419,14 @@ static void imap_client_destroy(struct client *client)
                cmd_id_free(imap_client);
        }
 
-       settings_free(imap_client->set);
+       /* The client may live on as proxying, even though the imap-specific
+          parts get freed. Clear out the settings instance, so it's not
+          attempted to be used anymore. Alternatively we could delay freeing
+          it until the client is freed, but that would require more changes. */
+       event_set_ptr(client->event, SETTINGS_EVENT_INSTANCE, NULL);
        settings_instance_free(&imap_client->set_instance);
+
+       settings_free(imap_client->set);
        i_free_and_null(imap_client->proxy_backend_capability);
        imap_parser_unref(&imap_client->parser);
 }