From 8b7c28da67efca96148c1765e841afdbc78f6802 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Mon, 18 Oct 2010 19:50:32 -0400 Subject: [PATCH] Fixed a few potential memory leaks. --- src/commands.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/commands.c b/src/commands.c index 9f21c6b6..d12b1cb1 100644 --- a/src/commands.c +++ b/src/commands.c @@ -686,8 +686,11 @@ static gpg_error_t open_command_common(assuan_context_t ctx, gchar *line) if (req[1] && *req[1]) { rc = hash_key(client, req[1]); - if (rc) + if (rc) { + pth_cleanup_pop(1); + cleanup_client(client); return client->opts & OPT_INQUIRE ? rc : send_error(ctx, rc); + } } pth_cleanup_pop(1); @@ -804,14 +807,20 @@ static gpg_error_t open_command_common(assuan_context_t ctx, gchar *line) rc = hash_key(client, req[1]); - if (rc) + if (rc) { + pth_cleanup_pop(1); + cleanup_client(client); return client->opts & OPT_INQUIRE ? rc : send_error(ctx, rc); + } } else if (req && req[1] && *req[1]) { rc = hash_key(client, req[1]); - if (rc) + if (rc) { + pth_cleanup_pop(1); + cleanup_client(client); return client->opts & OPT_INQUIRE ? rc : send_error(ctx, rc); + } } done: @@ -1364,8 +1373,10 @@ static gpg_error_t save_command_finalize(assuan_context_t ctx, guchar *key, client->crypto->key = key; rc = update_element_mtime(xmlDocGetRootElement(client->doc)); - if (rc) + if (rc) { + cleanup_crypto(&client->crypto); return client->opts & OPT_INQUIRE ? rc : send_error(ctx, rc); + } xmlDocDumpFormatMemory(client->doc, (xmlChar **)&xmlbuf, (gint *)&len, 0); pth_cleanup_push(xmlFree, xmlbuf); @@ -1628,14 +1639,18 @@ static gpg_error_t save_command_common(assuan_context_t ctx, gchar *line) client->opts |= OPT_ITERATIONS; rc = send_status(ctx, STATUS_CONFIG, NULL); - if (rc) + if (rc) { + cleanup_crypto(&client->crypto); return client->opts & OPT_INQUIRE ? rc : send_error(ctx, rc); + } } rc = hash_key(client, line); - if (rc) + if (rc) { + cleanup_crypto(&client->crypto); return client->opts & OPT_INQUIRE ? rc : send_error(ctx, rc); + } } done: -- 2.11.4.GIT