Added quick fix for empty message ID test_diphoton
authorKrista Bennett <krista@pep-project.org>
Wed, 25 Oct 2017 12:17:24 +0200
branchtest_diphoton
changeset 22051cb06c1241bd
parent 2202 b9c91491949f
parent 2204 765c6ff31183
child 2206 3387acfea51f
Added quick fix for empty message ID
src/message_api.c
     1.1 --- a/src/message_api.c	Wed Oct 25 11:17:36 2017 +0200
     1.2 +++ b/src/message_api.c	Wed Oct 25 12:17:24 2017 +0200
     1.3 @@ -775,10 +775,8 @@
     1.4          _envelope = extract_minimal_envelope(attachment, PEP_dir_outgoing);
     1.5          status = generate_message_id(_envelope);
     1.6          
     1.7 -        if (status != PEP_STATUS_OK) {
     1.8 -            free(_envelope);
     1.9 -            return NULL;
    1.10 -        }
    1.11 +        if (status != PEP_STATUS_OK)
    1.12 +            goto enomem;
    1.13          
    1.14          attachment->longmsg = encapsulate_message_wrap_info("INNER", attachment->longmsg);
    1.15          _envelope->longmsg = encapsulate_message_wrap_info("OUTER", _envelope->longmsg);
    1.16 @@ -786,6 +784,19 @@
    1.17      else {
    1.18          _envelope->longmsg = encapsulate_message_wrap_info("TRANSPORT", _envelope->longmsg);
    1.19      }
    1.20 +    
    1.21 +    if (!attachment->id || attachment->id[0] == "\0") {
    1.22 +        free(attachment->id);
    1.23 +        if (!_envelope->id) {
    1.24 +            status = generate_message_id(_envelope);
    1.25 +        
    1.26 +            if (status != PEP_STATUS_OK)
    1.27 +                goto enomem;
    1.28 +        }
    1.29 +            
    1.30 +        attachment->id = strdup(_envelope->id);
    1.31 +    }
    1.32 +    
    1.33      char* message_text = NULL;
    1.34  
    1.35      /* prevent introduction of pEp in inner message */
    1.36 @@ -814,7 +825,7 @@
    1.37      
    1.38  enomem:
    1.39      if (!envelope) {
    1.40 -        free(_envelope);
    1.41 +        free_message(_envelope);
    1.42      }
    1.43      return NULL;    
    1.44  }