From: Timo Sirainen Date: Tue, 12 Jun 2018 13:56:51 +0000 (+0300) Subject: mail-crypt: Fix memory leak in "doveadm mailbox cryptokey generate" X-Git-Tag: 2.3.9~1725 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2453834bce8ac340695f990d7bff617404c28af2;p=thirdparty%2Fdovecot%2Fcore.git mail-crypt: Fix memory leak in "doveadm mailbox cryptokey generate" --- diff --git a/src/plugins/mail-crypt/doveadm-mail-crypt.c b/src/plugins/mail-crypt/doveadm-mail-crypt.c index 612f469ba9..e7a83d8bc7 100644 --- a/src/plugins/mail-crypt/doveadm-mail-crypt.c +++ b/src/plugins/mail-crypt/doveadm-mail-crypt.c @@ -342,6 +342,7 @@ static int mcp_keypair_generate_run(struct doveadm_mail_cmd_context *_ctx, key_id, &error)) { i_error("dcrypt_key_id_public() failed: %s", error); + dcrypt_key_unref_public(&user_key); return -1; } const char *hash = binary_to_hex(key_id->data, @@ -351,6 +352,7 @@ static int mcp_keypair_generate_run(struct doveadm_mail_cmd_context *_ctx, res->id = p_strdup(_ctx->pool, hash); res->success = TRUE; ctx->matched_keys++; + dcrypt_key_unref_public(&user_key); return 1; } struct dcrypt_keypair pair; @@ -371,8 +373,10 @@ static int mcp_keypair_generate_run(struct doveadm_mail_cmd_context *_ctx, ctx->matched_keys++; } - if (ctx->userkey_only) + if (ctx->userkey_only) { + dcrypt_key_unref_public(&user_key); return 0; + } const char *const *patterns = (const char *const[]){ "*", NULL };