[Commits] [SCM] claws branch, master, updated. 3.15.0-96-g11980bc
ticho at claws-mail.org
ticho at claws-mail.org
Tue Jul 11 21:10:32 CEST 2017
The branch, master has been updated
via 11980bc7a384136cc2d9aada20988bcd462b1ffc (commit)
from 2103e3787ab8ef2c8eb43d35292e5c91b5b61237 (commit)
Summary of changes:
src/plugins/pgpcore/autocompletion.c | 2 +-
src/plugins/pgpcore/select-keys.c | 10 ++++++++--
src/plugins/pgpcore/sgpgme.c | 25 ++++++++++++++++---------
3 files changed, 25 insertions(+), 12 deletions(-)
- Log -----------------------------------------------------------------
commit 11980bc7a384136cc2d9aada20988bcd462b1ffc
Author: Andrej Kacian <ticho at claws-mail.org>
Date: Tue Jul 11 21:09:24 2017 +0200
Fix a few memory leaks when enumerating keys with GpgME.
Also replaced uses of deprecated gpgme_key_release()
with gpgme_key_unref().
diff --git a/src/plugins/pgpcore/autocompletion.c b/src/plugins/pgpcore/autocompletion.c
index 286f241..a4f15a6 100644
--- a/src/plugins/pgpcore/autocompletion.c
+++ b/src/plugins/pgpcore/autocompletion.c
@@ -100,7 +100,7 @@ static gboolean pgp_autocompletion_hook(gpointer source, gpointer data)
i++;
}
}
- gpgme_key_release(key);
+ gpgme_key_unref(key);
}
gpgme_release(ctx);
}
diff --git a/src/plugins/pgpcore/select-keys.c b/src/plugins/pgpcore/select-keys.c
index 69a7f8a..47e4b66 100644
--- a/src/plugins/pgpcore/select-keys.c
+++ b/src/plugins/pgpcore/select-keys.c
@@ -167,7 +167,7 @@ static void
destroy_key (gpointer data)
{
gpgme_key_t key = data;
- gpgme_key_release (key);
+ gpgme_key_unref (key);
}
static void
@@ -320,6 +320,8 @@ fill_clist (struct select_keys_s *sk, const char *pattern, gpgme_protocol_t prot
g_free(raw_mail);
}
num_results++;
+ if (last_key != NULL)
+ gpgme_key_unref(last_key);
last_key = key;
key = NULL;
update_progress (sk, ++running, pattern);
@@ -344,7 +346,11 @@ fill_clist (struct select_keys_s *sk, const char *pattern, gpgme_protocol_t prot
gpgme_release (ctx);
}
/*gtk_cmclist_thaw (select_keys.clist);*/
- return (exact_match == TRUE && num_results == 1 ? last_key:NULL);
+ if (exact_match && num_results == 1)
+ return last_key;
+
+ gpgme_key_unref(last_key);
+ return NULL;
}
diff --git a/src/plugins/pgpcore/sgpgme.c b/src/plugins/pgpcore/sgpgme.c
index 2290526..0579f42 100644
--- a/src/plugins/pgpcore/sgpgme.c
+++ b/src/plugins/pgpcore/sgpgme.c
@@ -607,37 +607,43 @@ gboolean sgpgme_setup_signers(gpgme_ctx_t ctx, PrefsAccount *account,
/* Look for any key, not just private ones, or GPGMe doesn't
* correctly set the revoked flag. */
err = gpgme_op_keylist_start(ctx, keyid, 0);
- while ((err = gpgme_op_keylist_next(ctx, &key)) == 0) {
+ while (err == 0) {
+ if ((err = gpgme_op_keylist_next(ctx, &key)) != 0)
+ break;
+
if (key == NULL)
continue;
- if (!key->can_sign)
+ if (!key->can_sign) {
+ debug_print("skipping a key, can not be used for signing\n");
+ gpgme_key_unref(key);
continue;
+ }
if (key->protocol != gpgme_get_protocol(ctx)) {
debug_print("skipping a key (wrong protocol %d)\n", key->protocol);
- gpgme_key_release(key);
+ gpgme_key_unref(key);
continue;
}
if (key->expired) {
debug_print("skipping a key, expired\n");
- gpgme_key_release(key);
+ gpgme_key_unref(key);
continue;
}
if (key->revoked) {
debug_print("skipping a key, revoked\n");
- gpgme_key_release(key);
+ gpgme_key_unref(key);
continue;
}
if (key->disabled) {
debug_print("skipping a key, disabled\n");
- gpgme_key_release(key);
+ gpgme_key_unref(key);
continue;
}
if (found_key != NULL) {
- gpgme_key_release(key);
+ gpgme_key_unref(key);
gpgme_op_keylist_end(ctx);
g_warning("ambiguous specification of secret key '%s'", keyid);
privacy_set_error(_("Secret key specification is ambiguous"));
@@ -645,7 +651,7 @@ gboolean sgpgme_setup_signers(gpgme_ctx_t ctx, PrefsAccount *account,
}
found_key = key;
- }
+ }
gpgme_op_keylist_end(ctx);
if (found_key == NULL) {
@@ -658,7 +664,7 @@ gboolean sgpgme_setup_signers(gpgme_ctx_t ctx, PrefsAccount *account,
debug_print("got key (proto %d (pgp %d, smime %d).\n",
found_key->protocol, GPGME_PROTOCOL_OpenPGP,
GPGME_PROTOCOL_CMS);
- gpgme_key_release(found_key);
+ gpgme_key_unref(found_key);
if (err) {
g_warning("error adding secret key: %s",
@@ -1094,6 +1100,7 @@ check_again:
err = gpgme_op_keylist_start(ctx, NULL, TRUE);
if (!err)
err = gpgme_op_keylist_next(ctx, &key);
+ gpgme_key_unref(key); /* We're not interested in the key itself. */
gpgme_op_keylist_end(ctx);
if (gpg_err_code(err) == GPG_ERR_EOF) {
if (gpgme_get_protocol(ctx) != GPGME_PROTOCOL_CMS) {
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list