]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: mail_user_var_expand_table() - Fix excessive memory usage
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 18 Mar 2024 11:52:37 +0000 (13:52 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 18 Mar 2024 11:52:37 +0000 (13:52 +0200)
It was supposed to return a cached table, but instead it now allocated a new
one every time from mail_user's pool. This kept growing memory usage after
every mail_user_var_expand_table() call.

Broken by 10eaf04197cfe7f6ab1fd4ab57c9f38e75b2889d

src/lib-storage/mail-user.c

index 47b9f321c70577263d5dc4a84251785e9140a917..ba0cd7bf5cf402e6ac38149e3dd6666ce7a5386e 100644 (file)
@@ -280,6 +280,10 @@ void mail_user_set_vars(struct mail_user *user, const char *service,
 const struct var_expand_table *
 mail_user_var_expand_table(struct mail_user *user)
 {
+       /* use a cached table if possible */
+       if (user->var_expand_table != NULL)
+               return user->var_expand_table;
+
        const char *username =
                p_strdup(user->pool, t_strcut(user->username, '@'));
        const char *domain = i_strchr_to_next(user->username, '@');