...
authorvb
Tue, 30 Dec 2014 23:35:24 +0100
changeset 42d7263ab3b539
parent 41 b30cc1842d9c
child 43 816f4ccf84da
...
src/message_api.c
     1.1 --- a/src/message_api.c	Tue Dec 30 23:33:42 2014 +0100
     1.2 +++ b/src/message_api.c	Tue Dec 30 23:35:24 2014 +0100
     1.3 @@ -176,38 +176,40 @@
     1.4                  }
     1.5              }
     1.6              if (msg) {
     1.7 -                bloblist_t *_s;
     1.8 -                bloblist_t *_d = new_bloblist(NULL, 0, NULL, NULL);
     1.9 -                if (_d == NULL) {
    1.10 -                    free_message(msg);
    1.11 -                    free_stringlist(keys);
    1.12 -                    return PEP_OUT_OF_MEMORY;
    1.13 -                }
    1.14 -                msg->attachments = _d;
    1.15 -                for (_s = src->attachments; _s && _s->data; _s = _s->next) {
    1.16 -                    int psize = _s->size;
    1.17 -                    ptext = _s->data;
    1.18 -                    status = encrypt_and_sign(session, keys, ptext, psize,
    1.19 -                            &ctext, &csize);
    1.20 -                    if (ctext) {
    1.21 -                        char * _c = strdup(ctext);
    1.22 -                        if (_c == NULL) {
    1.23 +                if (src->attachments) {
    1.24 +                    bloblist_t *_s;
    1.25 +                    bloblist_t *_d = new_bloblist(NULL, 0, NULL, NULL);
    1.26 +                    if (_d == NULL) {
    1.27 +                        free_message(msg);
    1.28 +                        free_stringlist(keys);
    1.29 +                        return PEP_OUT_OF_MEMORY;
    1.30 +                    }
    1.31 +                    msg->attachments = _d;
    1.32 +                    for (_s = src->attachments; _s && _s->data; _s = _s->next) {
    1.33 +                        int psize = _s->size;
    1.34 +                        ptext = _s->data;
    1.35 +                        status = encrypt_and_sign(session, keys, ptext, psize,
    1.36 +                                &ctext, &csize);
    1.37 +                        if (ctext) {
    1.38 +                            char * _c = strdup(ctext);
    1.39 +                            if (_c == NULL) {
    1.40 +                                free_message(msg);
    1.41 +                                free_stringlist(keys);
    1.42 +                                return PEP_OUT_OF_MEMORY;
    1.43 +                            }
    1.44 +                            _d = bloblist_add(_d, _c, csize, _s->mime_type,
    1.45 +                                    _s->file_name);
    1.46 +                            if (_d == NULL) {
    1.47 +                                free_message(msg);
    1.48 +                                free_stringlist(keys);
    1.49 +                                return PEP_OUT_OF_MEMORY;
    1.50 +                            }
    1.51 +                        }
    1.52 +                        else {
    1.53                              free_message(msg);
    1.54 -                            free_stringlist(keys);
    1.55 -                            return PEP_OUT_OF_MEMORY;
    1.56 +                            msg = NULL;
    1.57 +                            break;
    1.58                          }
    1.59 -                        _d = bloblist_add(_d, _c, csize, _s->mime_type,
    1.60 -                                _s->file_name);
    1.61 -                        if (_d == NULL) {
    1.62 -                            free_message(msg);
    1.63 -                            free_stringlist(keys);
    1.64 -                            return PEP_OUT_OF_MEMORY;
    1.65 -                        }
    1.66 -                    }
    1.67 -                    else {
    1.68 -                        free_message(msg);
    1.69 -                        msg = NULL;
    1.70 -                        break;
    1.71                      }
    1.72                  }
    1.73                  msg->enc_format = PEP_enc_pieces;