destroy_key (gpointer data)
{
gpgme_key_t key = data;
- gpgme_key_release (key);
+ gpgme_key_unref (key);
}
static void
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);
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;
}
/* 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"));
}
found_key = key;
- }
+ }
gpgme_op_keylist_end(ctx);
if (found_key == NULL) {
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",
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) {