From: Timo Sirainen Date: Mon, 18 Mar 2024 11:52:37 +0000 (+0200) Subject: lib-storage: mail_user_var_expand_table() - Fix excessive memory usage X-Git-Tag: 2.4.0~1711 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8f4ac53fa30f813b595bc944aff6c653d2bbf8f;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: mail_user_var_expand_table() - Fix excessive memory usage 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 --- diff --git a/src/lib-storage/mail-user.c b/src/lib-storage/mail-user.c index 47b9f321c7..ba0cd7bf5c 100644 --- a/src/lib-storage/mail-user.c +++ b/src/lib-storage/mail-user.c @@ -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, '@');