attempt to fix double-free related to recipient count Release_2.1.0-RC39
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Fri, 02 Oct 2020 17:05:02 +0200
changeset 50705f16965452aa
parent 5069 f9eea5336b3b
child 5071 b6c68213a07e
attempt to fix double-free related to recipient count
src/pgp_sequoia.c
     1.1 --- a/src/pgp_sequoia.c	Fri Oct 02 16:58:43 2020 +0200
     1.2 +++ b/src/pgp_sequoia.c	Fri Oct 02 17:05:02 2020 +0200
     1.3 @@ -2140,12 +2140,15 @@
     1.4      ws = pgp_encryptor_new (&err, ws,
     1.5                              NULL, 0, recipients, recipient_count,
     1.6                              0, 0);
     1.7 +    // pgp_encrypt_new consumes the recipients (but not the keys).
     1.8 +    // This seems to still happen even if it failed, so we need to be sure
     1.9 +    // not to try to free them if we bail.
    1.10 +    recipient_count = 0;
    1.11 +
    1.12      if (!ws)
    1.13          ERROR_OUT(err, PEP_UNKNOWN_ERROR, "Setting up encryptor");
    1.14  
    1.15 -    // pgp_encrypt_new consumes the recipients (but not the keys).
    1.16 -    recipient_count = 0;
    1.17 -
    1.18 + 
    1.19      if (sign) {            
    1.20          
    1.21          iter = pgp_cert_valid_key_iter(signer_cert, session->policy, 0);