]> granicus.if.org Git - mutt/commitdiff
Fix gpgme segfault in create_recipient_set().
authorKevin McCarthy <kevin@8t8.us>
Sun, 16 Oct 2016 21:16:47 +0000 (14:16 -0700)
committerKevin McCarthy <kevin@8t8.us>
Sun, 16 Oct 2016 21:16:47 +0000 (14:16 -0700)
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.

crypt-gpgme.c

index 6d8f333681edaaa665f963a14da4d1a16c2a4a0d..aab9a6e2b2f91eb827e533b98eb285a937e8daf2 100644 (file)
@@ -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;
              }