diff options
author | Kevin McCarthy <kevin@8t8.us> | 2016-10-17 11:22:13 -0700 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2016-10-17 11:22:13 -0700 |
commit | d710f26ad436b0fa18274f26a2af93d461a3587d (patch) | |
tree | e3885dd513fbaf57e0194d16d6b35049c78eed4c /crypt-gpgme.c | |
parent | d733189063f55f6ed621feba6514eacad271cdc6 (diff) |
Actually fix gpgme segfault in create_recipient_set().
Changeset 6e44bfa16096 did not fix the segv. (Sorry, I made the fix
based off a report on IRC but didn't trigger the segv myself: it was
caused by an out-of-tree patch).
The actual problem was that the rset was only resized on a successful
gpgme_get_key(). However, on error, the array still needs to be
NULL-terminated before calling free_recipient_set().
Move the resize so it always takes place. This obviates the need for
the NULL check added in 6e44bfa16096.
Diffstat (limited to 'crypt-gpgme.c')
-rw-r--r-- | crypt-gpgme.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/crypt-gpgme.c b/crypt-gpgme.c index aab9a6e2..c972afc2 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -673,20 +673,15 @@ static gpgme_key_t *create_recipient_set (const char *keylist, else err = gpgme_get_key (context, buf, &key, 0); + safe_realloc (&rset, sizeof (*rset) * (rset_n + 1)); if (! err) - { - safe_realloc (&rset, sizeof (*rset) * (rset_n + 1)); - rset[rset_n++] = key; - } + rset[rset_n++] = key; else { mutt_error (_("error adding recipient `%s': %s\n"), buf, gpgme_strerror (err)); - if (rset) - { - rset[rset_n] = NULL; - free_recipient_set (&rset); - } + rset[rset_n] = NULL; + free_recipient_set (&rset); gpgme_release (context); return NULL; } |