]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Changed mail_user refcounting to fix deinitialization.
authorTimo Sirainen <tss@iki.fi>
Fri, 21 Nov 2008 19:19:16 +0000 (21:19 +0200)
committerTimo Sirainen <tss@iki.fi>
Fri, 21 Nov 2008 19:19:16 +0000 (21:19 +0200)
--HG--
branch : HEAD

src/lib-storage/mail-namespace.c

index a262a12140096274205c0f745095c45acbe0c6a2..f7e0cedaea575288969a242c75941b4244715bce 100644 (file)
@@ -29,7 +29,7 @@ void mail_namespace_init_storage(struct mail_namespace *ns)
 
 static void mail_namespace_free(struct mail_namespace *ns)
 {
-       if (ns->owner != NULL)
+       if (ns->owner != ns->user && ns->owner != NULL)
                mail_user_unref(&ns->owner);
        i_free(ns->prefix);
        i_free(ns);
@@ -65,7 +65,6 @@ namespace_add_env(const char *data, unsigned int num,
        if (type == NULL || *type == '\0' || strncmp(type, "private", 7) == 0) {
                ns->type = NAMESPACE_PRIVATE;
                ns->owner = user;
-               mail_user_ref(ns->owner);
        } else if (strncmp(type, "shared", 6) == 0)
                ns->type = NAMESPACE_SHARED;
        else if (strncmp(type, "public", 6) == 0)
@@ -252,7 +251,6 @@ int mail_namespaces_init(struct mail_user *user)
        ns->prefix = i_strdup("");
        ns->user = user;
        ns->owner = user;
-       mail_user_ref(ns->owner);
 
        if (mail_storage_create(ns, NULL, mail, flags, lock_method,
                                &error) < 0) {
@@ -283,7 +281,6 @@ mail_namespaces_init_empty(struct mail_user *user)
        ns = i_new(struct mail_namespace, 1);
        ns->user = user;
        ns->owner = user;
-       mail_user_ref(ns->owner);
        ns->prefix = i_strdup("");
        ns->flags = NAMESPACE_FLAG_INBOX | NAMESPACE_FLAG_LIST_PREFIX |
                NAMESPACE_FLAG_SUBSCRIPTIONS;