to NULL. */
static void crypt_free_key (crypt_key_t **keylist)
{
+ crypt_key_t *k;
+
+ if (!keylist)
+ return;
+
while (*keylist)
- {
- crypt_key_t *k = (*keylist)->next;
- FREE (&k);
- *keylist = k;
- }
+ {
+ k = *keylist;
+ *keylist = (*keylist)->next;
+
+ gpgme_key_unref (k->kobj);
+ FREE (&k);
+ }
}
/* Return trute when key K is valid. */
}
+static void free_recipient_set (gpgme_key_t **p_rset)
+{
+ gpgme_key_t *rset, k;
+
+ if (!p_rset)
+ return;
+
+ rset = *p_rset;
+ if (!rset)
+ return;
+
+ while (*rset)
+ {
+ k = *rset;
+ gpgme_key_unref (k);
+ rset++;
+ }
+
+ FREE (p_rset); /* __FREE_CHECKED__ */
+}
+
+
/* Create a GpgmeRecipientSet from the keys in the string KEYLIST.
The keys must be space delimited. */
static gpgme_key_t *create_recipient_set (const char *keylist,
{
mutt_error (_("error adding recipient `%s': %s\n"),
buf, gpgme_strerror (err));
- FREE (&rset);
+ rset[rset_n] = NULL;
+ free_recipient_set (&rset);
+ gpgme_release (context);
return NULL;
}
}
err = gpgme_op_keylist_next (listctx, &key2);
if (!err)
{
- gpgme_key_release (key);
- gpgme_key_release (key2);
+ gpgme_key_unref (key);
+ gpgme_key_unref (key2);
gpgme_release (listctx);
mutt_error (_("ambiguous specification of secret key `%s'\n"),
signid);
gpgme_signers_clear (ctx);
err = gpgme_signers_add (ctx, key);
- gpgme_key_release (key);
+ gpgme_key_unref (key);
if (err)
{
mutt_error (_("error setting secret key `%s': %s\n"),
if (set_signer (ctx, use_smime))
{
gpgme_data_release (signature);
+ gpgme_data_release (message);
gpgme_release (ctx);
return NULL;
}
plaintext = body_to_data_object (a, 0);
if (!plaintext)
{
- FREE (&rset);
+ free_recipient_set (&rset);
return NULL;
}
outfile = encrypt_gpgme_object (plaintext, rset, 0, sign);
gpgme_data_release (plaintext);
- FREE (&rset);
+ free_recipient_set (&rset);
if (!outfile)
return NULL;
plaintext = body_to_data_object (a, 0);
if (!plaintext)
{
- FREE (&rset);
+ free_recipient_set (&rset);
return NULL;
}
outfile = encrypt_gpgme_object (plaintext, rset, 1, 0);
gpgme_data_release (plaintext);
- FREE (&rset);
+ free_recipient_set (&rset);
if (!outfile)
return NULL;
if (signature_key)
{
- gpgme_key_release (signature_key);
+ gpgme_key_unref (signature_key);
signature_key = NULL;
}
}
if (key != signature_key)
- gpgme_key_release (key);
+ gpgme_key_unref (key);
}
return anybad ? 1 : anywarn ? 2 : 0;
state_attach_puts (_("[-- Begin signature information --]\n"), s);
err = gpgme_op_verify (ctx, signature, message, NULL);
+ gpgme_data_release (message);
+ gpgme_data_release (signature);
+
mutt_need_hard_redraw ();
if (err)
{
if (signature_key)
{
- gpgme_key_release (signature_key);
+ gpgme_key_unref (signature_key);
signature_key = NULL;
}
subkey = subkey->next;
more = 1;
}
- gpgme_key_release (key);
+ gpgme_key_unref (key);
}
if (gpg_err_code (err) != GPG_ERR_EOF)
{
FREE (&tmpfname);
}
}
+ gpgme_data_release (plaintext);
gpgme_release (ctx);
}
state_attach_puts (_("[-- END PGP SIGNED MESSAGE --]\n"), s);
}
+ gpgme_data_release (armored_data);
if (pgpout)
{
safe_fclose (&pgpout);
{
putc ('\n', fp);
err = gpgme_op_keylist_start (listctx, s, 0);
- gpgme_key_release (k);
+ gpgme_key_unref (k);
k = NULL;
if (!err)
err = gpgme_op_keylist_next (listctx, &k);
}
leave:
- gpgme_key_release (k);
+ gpgme_key_unref (k);
gpgme_release (listctx);
safe_fclose (&fp);
mutt_clear_error ();
{
k = safe_calloc (1, sizeof *k);
k->kobj = key;
+ gpgme_key_ref (k->kobj);
k->idx = idx;
k->uid = uid->uid;
k->flags = flags;
*kend = k;
kend = &k->next;
}
+ gpgme_key_unref (key);
}
if (gpg_err_code (err) != GPG_ERR_EOF)
mutt_error (_("gpgme_op_keylist_next failed: %s"), gpgme_strerror (err));
{
k = safe_calloc (1, sizeof *k);
k->kobj = key;
+ gpgme_key_ref (k->kobj);
k->idx = idx;
k->uid = uid->uid;
k->flags = flags;
*kend = k;
kend = &k->next;
}
+ gpgme_key_unref (key);
}
if (gpg_err_code (err) != GPG_ERR_EOF)
mutt_error (_("gpgme_op_keylist_next failed: %s"), gpgme_strerror (err));
if (signature_key)
{
- gpgme_key_release (signature_key);
+ gpgme_key_unref (signature_key);
signature_key = NULL;
}