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.
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) {
}
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);
}