# HG changeset patch # User Timo Sirainen # Date 1486723288 -7200 # Node ID 3b1b633a40cce5c605fb095f0ee5a5e992214970 # Parent be3236bce027359695fcc78b1cd3e73fa71fb266 mail-crypt-acl: Fix error handling Don't crash if mail_user creation failed. diff -r be3236bce027 -r 3b1b633a40cc src/plugins/mail-crypt/mail-crypt-acl-plugin.c --- a/src/plugins/mail-crypt/mail-crypt-acl-plugin.c Fri Feb 10 12:40:41 2017 +0200 +++ b/src/plugins/mail-crypt/mail-crypt-acl-plugin.c Fri Feb 10 12:41:28 2017 +0200 @@ -272,7 +272,8 @@ &dest_service_user, &error); /* to make sure we get correct logging context */ - mail_storage_service_io_deactivate_user(dest_service_user); + if (ret > 0) + mail_storage_service_io_deactivate_user(dest_service_user); mail_storage_service_io_activate_user( aclobj->backend->list->ns->user->_service_user ); @@ -281,6 +282,7 @@ i_error("mail-crypt-acl-plugin: " "Cannot initialize destination user %s: %s", username, error); + break; } else { i_assert(dest_user != NULL); if ((ret = mail_crypt_acl_update_private_key(box, dest_user, @@ -301,10 +303,8 @@ ); mail_storage_service_io_activate_user(dest_service_user); - if (dest_user != NULL) - mail_user_unref(&dest_user); - if (dest_service_user != NULL) - mail_storage_service_user_free(&dest_service_user); + mail_user_unref(&dest_user); + mail_storage_service_user_free(&dest_service_user); if ((cur_ioloop_ctx = io_loop_get_current_context(current_ioloop)) != NULL) io_loop_context_deactivate(cur_ioloop_ctx);