]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fix memory leaks when storage create() fails
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 20 Dec 2024 08:36:27 +0000 (10:36 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:40:02 +0000 (10:40 +0200)
src/lib-storage/mail-storage.c

index 7149217872600ecf9cd65b2a81cb89dcda250ec0..e5d47d4086fa00f7cd096cba38d44f86430217d5 100644 (file)
@@ -512,6 +512,7 @@ mail_storage_create_real(struct mail_namespace *ns, struct event *set_event,
        if (storage->v.create != NULL &&
            storage->v.create(storage, ns, error_r) < 0) {
                *error_r = t_strdup_printf("%s: %s", storage->name, *error_r);
+               storage->v.destroy(storage);
                settings_free(storage->set);
                event_unref(&storage->event);
                pool_unref(&storage->pool);
@@ -548,6 +549,9 @@ mail_storage_create_real(struct mail_namespace *ns, struct event *set_event,
                        *error_r = t_strdup_printf("fs_init(posix) failed: %s", error);
                        event_unref(&event);
                        storage->v.destroy(storage);
+                       settings_free(storage->set);
+                       event_unref(&storage->event);
+                       pool_unref(&storage->pool);
                        return -1;
                }
                event_unref(&event);