]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mail-compress: Fix panic when save method unavailable
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sat, 25 Apr 2026 20:04:40 +0000 (20:04 +0000)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Thu, 30 Apr 2026 06:36:37 +0000 (06:36 +0000)
When mail_compress_write_method points to a compression handler that's
unknown or not compiled in, user creation correctly fails by setting
user->error. The bug: vlast and v->deinit were chained before
MODULE_CONTEXT_SET, so the early return left a deinit hook in place
without the corresponding module context. Cleanup later panicked with:

  Panic: Module context mail_compress_user_module missing

Defer the vlast/deinit install until after MODULE_CONTEXT_SET so the
hook only fires for users that actually have the context attached.

src/plugins/mail-compress/mail-compress-plugin.c

index 1adbed5ae6605edd49ef6412d4681902d498e803..c0d9ea65b344984943f89520f779ab0ad7049732 100644 (file)
@@ -370,9 +370,6 @@ static void mail_compress_mail_user_created(struct mail_user *user)
        int ret;
 
        zuser = p_new(user->pool, struct mail_compress_user, 1);
-       zuser->module_ctx.super = *v;
-       user->vlast = &zuser->module_ctx.super;
-       v->deinit = mail_compress_mail_user_deinit;
 
        if (settings_get(user->event, &mail_compress_setting_parser_info, 0,
                         &set, &error) < 0) {
@@ -394,6 +391,9 @@ static void mail_compress_mail_user_created(struct mail_user *user)
        }
        settings_free(set);
 
+       zuser->module_ctx.super = *v;
+       user->vlast = &zuser->module_ctx.super;
+       v->deinit = mail_compress_mail_user_deinit;
        MODULE_CONTEXT_SET(user, mail_compress_user_module, zuser);
 }