Skip to content

Commit

Permalink
mail-crypt: Fix memory leak in "doveadm mailbox cryptokey generate"
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen committed Aug 22, 2018
1 parent 06ce326 commit e9e2cda
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/plugins/mail-crypt/doveadm-mail-crypt.c
Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -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 };

Expand Down

0 comments on commit e9e2cda

Please sign in to comment.