--- src/plugins/quota/quota-status.c	2015-12-09 16:39:11.000000000 +0100
+++ src/plugins/quota/quota-status.c	2016-02-07 21:16:54.000000000 +0100
@@ -49,13 +49,15 @@
 quota_check(struct mail_user *user, uoff_t mail_size,
 	    const char **error_r, bool *too_large_r)
 {
-	struct quota_user *quser = QUOTA_USER_CONTEXT(user);
+	struct quota_user *quser;
 	struct mail_namespace *ns;
 	struct mailbox *box;
 	struct quota_transaction_context *ctx;
+	struct quota_settings *quota_set;
 	int ret;

-	if (quser == NULL) {
+	quota_mail_user_created(user);
+	if ((quser = QUOTA_USER_CONTEXT(user)) == NULL) {
 		/* no quota for user */
 		return 1;
 	}
@@ -73,6 +75,12 @@
 		*error_r = "Internal quota calculation error";
 	else if (ret == 0)
 		*error_r = t_strdup(quser->quota->set->quota_exceeded_msg);
+
+	quota_set = quser->quota->set;
+	quota_deinit(&quser->quota);
+	quser->module_ctx.super.deinit(user);
+	quota_settings_deinit(&quota_set);
+
 	return ret;
 }

