Merging in ENGINE-199 to get changes for ENGINE-198 because I am a doofus.
authorKrista Bennett <krista@pep-project.org>
Tue, 09 May 2017 14:13:23 +0200
changeset 17709d19fa238f63
parent 1767 bca5879ada6e
parent 1769 07b5567daaee
child 1772 4a6cee288e58
Merging in ENGINE-199 to get changes for ENGINE-198 because I am a doofus.
     1.1 --- a/src/message_api.c	Tue May 09 14:00:24 2017 +0200
     1.2 +++ b/src/message_api.c	Tue May 09 14:13:23 2017 +0200
     1.3 @@ -2506,10 +2506,14 @@
     1.4                                                  rating,
     1.5                                                  flags);
     1.6                                                  
     1.7 -    if (!dec_msg && (decrypt_status == PEP_UNENCRYPTED || decrypt_status == PEP_VERIFIED)) {
     1.8 -        dec_msg = message_dup(tmp_msg);
     1.9 +    bool dec_empty = (dec_msg == NULL);
    1.10 +
    1.11 +    if (dec_empty) {
    1.12 +        dec_msg = tmp_msg;
    1.13      }
    1.14          
    1.15 +    // This is for when errors are seriously fatal, not just decryption probs
    1.16 +    // Unlikely to happen.
    1.17      if (decrypt_status > PEP_CANNOT_DECRYPT_UNKNOWN)
    1.18      {
    1.19          status = decrypt_status;
    1.20 @@ -2528,13 +2532,15 @@
    1.21      if (status == PEP_STATUS_OK)
    1.22      {
    1.23          free(tmp_msg);
    1.24 -        free(dec_msg);
    1.25 +        if (!dec_empty)
    1.26 +            free(dec_msg);
    1.27          return ERROR(decrypt_status);
    1.28      }
    1.29      
    1.30  pep_error:
    1.31      free_message(tmp_msg);
    1.32 -    free_message(dec_msg);
    1.33 +    if (!dec_empty)
    1.34 +        free_message(dec_msg);
    1.35  
    1.36      return ERROR(status);
    1.37  }