summaryrefslogtreecommitdiffstats
path: root/crypt-gpgme.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2016-10-16 14:16:47 -0700
committerKevin McCarthy <kevin@8t8.us>2016-10-16 14:16:47 -0700
commitf3697a744da54089f5f58561e8ed44add5f7c0e0 (patch)
tree87a8b00b34301e6922d1ff9a3f6053c526381f01 /crypt-gpgme.c
parente38ae9b19021500dcf4e2ef62826455a8022af04 (diff)
Fix gpgme segfault in create_recipient_set().
If gpgme_get_key() errors on the first key, the rset will not be allocated yet. Attempting to null-terminate (and then free) the array causes a segfault.
Diffstat (limited to 'crypt-gpgme.c')
-rw-r--r--crypt-gpgme.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/crypt-gpgme.c b/crypt-gpgme.c
index 6d8f3336..aab9a6e2 100644
--- a/crypt-gpgme.c
+++ b/crypt-gpgme.c
@@ -682,8 +682,11 @@ static gpgme_key_t *create_recipient_set (const char *keylist,
{
mutt_error (_("error adding recipient `%s': %s\n"),
buf, gpgme_strerror (err));
- rset[rset_n] = NULL;
- free_recipient_set (&rset);
+ if (rset)
+ {
+ rset[rset_n] = NULL;
+ free_recipient_set (&rset);
+ }
gpgme_release (context);
return NULL;
}