]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Fixed a potential crash with dict quota at deinit.
authorTimo Sirainen <tss@iki.fi>
Mon, 28 Jun 2010 12:19:24 +0000 (13:19 +0100)
committerTimo Sirainen <tss@iki.fi>
Mon, 28 Jun 2010 12:19:24 +0000 (13:19 +0100)
--HG--
branch : HEAD

src/plugins/quota/quota.c

index 078978ed171eb2c9bee8076f8092d154fa40b047..a8ec7d27f41c66e4c7fc11dfffb01470c3d3ed4a 100644 (file)
@@ -282,11 +282,13 @@ void quota_deinit(struct quota **_quota)
        struct quota_root *const *roots;
        unsigned int i, count;
 
-       *_quota = NULL;
-
        roots = array_get(&quota->roots, &count);
        for (i = 0; i < count; i++)
                quota_root_deinit(roots[i]);
+
+       /* deinit quota roots before setting quser->quota=NULL */
+       *_quota = NULL;
+
        array_free(&quota->roots);
        array_free(&quota->namespaces);
        i_free(quota);
@@ -839,6 +841,8 @@ struct quota_transaction_context *quota_transaction_begin(struct mailbox *box)
        ctx->quota = box->list->ns->owner != NULL ?
                quota_get_mail_user_quota(box->list->ns->owner) :
                quota_get_mail_user_quota(box->list->ns->user);
+       i_assert(ctx->quota != NULL);
+
        ctx->box = box;
        ctx->bytes_left = (uint64_t)-1;
        ctx->count_left = (uint64_t)-1;