]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Don't crash when modifying non-private namespaces.
authorTimo Sirainen <tss@iki.fi>
Tue, 7 Apr 2009 16:26:50 +0000 (12:26 -0400)
committerTimo Sirainen <tss@iki.fi>
Tue, 7 Apr 2009 16:26:50 +0000 (12:26 -0400)
--HG--
branch : HEAD

src/plugins/quota/quota-storage.c

index 035fa9a8603f7803a359bd929a6a2028fcb0c2d9..443f8b2825124c76e87c8175dbf6b41cf12ea2f8 100644 (file)
@@ -511,21 +511,22 @@ void quota_mail_storage_created(struct mail_storage *storage)
        union mail_storage_module_context *qstorage;
        struct quota *quota;
 
+       if (qlist == NULL)
+               return;
+
        qlist->storage = storage;
 
-       qstorage = p_new(storage->pool, union mail_storage_module_context, 1);
+       qstorage = p_new(storage->pool,
+                        union mail_storage_module_context, 1);
        qstorage->super = storage->v;
        storage->v.destroy = quota_storage_destroy;
        storage->v.mailbox_open = quota_mailbox_open;
 
        MODULE_CONTEXT_SET_SELF(storage, quota_storage_module, qstorage);
 
-       if (storage->ns->owner != NULL &&
-           (storage->ns->flags & NAMESPACE_FLAG_INTERNAL) == 0) {
-               /* register to owner's quota roots */
-               quota = quota_get_mail_user_quota(storage->ns->owner);
-               quota_add_user_storage(quota, storage);
-       }
+       /* register to owner's quota roots */
+       quota = quota_get_mail_user_quota(storage->ns->owner);
+       quota_add_user_storage(quota, storage);
 
        if (quota_next_hook_mail_storage_created != NULL)
                quota_next_hook_mail_storage_created(storage);
@@ -535,12 +536,14 @@ void quota_mailbox_list_created(struct mailbox_list *list)
 {
        struct quota_mailbox_list *qlist;
 
-       qlist = p_new(list->pool, struct quota_mailbox_list, 1);
-       qlist->module_ctx.super = list->v;
-       list->v.delete_mailbox = quota_mailbox_list_delete;
-
-       MODULE_CONTEXT_SET(list, quota_mailbox_list_module, qlist);
+       if (list->ns->owner != NULL &&
+           (list->ns->flags & NAMESPACE_FLAG_INTERNAL) == 0) {
+               qlist = p_new(list->pool, struct quota_mailbox_list, 1);
+               qlist->module_ctx.super = list->v;
+               list->v.delete_mailbox = quota_mailbox_list_delete;
 
+               MODULE_CONTEXT_SET(list, quota_mailbox_list_module, qlist);
+       }
        if (quota_next_hook_mailbox_list_created != NULL)
                quota_next_hook_mailbox_list_created(list);
 }