fixes
authorVolker Birk <vb@pep-project.org>
Sun, 31 May 2015 18:26:37 +0200
changeset 38d314ed57180c
parent 37 863fc3ccd19d
child 39 6fc5cc7a167c
fixes
CpEpEngine.cpp
pEpCOMServerAdapter_i.c
pEpCOMServerAdapter_i.h
pEp_utitlity.cpp
utf8_helper.cpp
     1.1 --- a/CpEpEngine.cpp	Sun May 31 17:03:40 2015 +0200
     1.2 +++ b/CpEpEngine.cpp	Sun May 31 18:26:37 2015 +0200
     1.3 @@ -875,15 +875,18 @@
     1.4      ::stringlist_t *_extra = new_stringlist(extra);
     1.5  
     1.6      PEP_STATUS status = ::encrypt_message(get_session(), _src, _extra, &msg_dst, PEP_enc_pieces);
     1.7 -    free_message(_src);
     1.8 -    free_stringlist(_extra);
     1.9 -    if (status != PEP_STATUS_OK)
    1.10 +    ::free_stringlist(_extra);
    1.11 +    if (status != PEP_STATUS_OK && status != PEP_UNENCRYPTED) {
    1.12          FAIL(L"cannot encrypt message");
    1.13 +    }
    1.14  
    1.15 -    if (msg_dst) {
    1.16 +    if (status == PEP_UNENCRYPTED)
    1.17 +        text_message_from_C(dst, _src);
    1.18 +    else
    1.19          text_message_from_C(dst, msg_dst);
    1.20 -        free_message(msg_dst);
    1.21 -    }
    1.22 +
    1.23 +    ::free_message(msg_dst);
    1.24 +    ::free_message(_src);
    1.25  
    1.26      return S_OK;
    1.27  }
     2.1 --- a/pEpCOMServerAdapter_i.c	Sun May 31 17:03:40 2015 +0200
     2.2 +++ b/pEpCOMServerAdapter_i.c	Sun May 31 18:26:37 2015 +0200
     2.3 @@ -6,7 +6,7 @@
     2.4  
     2.5  
     2.6   /* File created by MIDL compiler version 8.00.0603 */
     2.7 -/* at Sun May 31 16:53:30 2015
     2.8 +/* at Sun May 31 17:28:45 2015
     2.9   */
    2.10  /* Compiler settings for pEpCOMServerAdapter.idl:
    2.11      Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0603 
     3.1 --- a/pEpCOMServerAdapter_i.h	Sun May 31 17:03:40 2015 +0200
     3.2 +++ b/pEpCOMServerAdapter_i.h	Sun May 31 18:26:37 2015 +0200
     3.3 @@ -4,7 +4,7 @@
     3.4  
     3.5  
     3.6   /* File created by MIDL compiler version 8.00.0603 */
     3.7 -/* at Sun May 31 16:53:30 2015
     3.8 +/* at Sun May 31 17:28:45 2015
     3.9   */
    3.10  /* Compiler settings for pEpCOMServerAdapter.idl:
    3.11      Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.00.0603 
     4.1 --- a/pEp_utitlity.cpp	Sun May 31 17:03:40 2015 +0200
     4.2 +++ b/pEp_utitlity.cpp	Sun May 31 18:26:37 2015 +0200
     4.3 @@ -197,7 +197,7 @@
     4.4              SafeArrayGetUBound(sa, 1, &ubound);
     4.5  
     4.6              T *_tl = tl;
     4.7 -            for (LONG i = lbound; i <= ubound; _tl = tl->next, i++)
     4.8 +            for (LONG i = lbound; i <= ubound; _tl = _tl->next, i++)
     4.9                  SafeArrayPutElement(sa, &i, from_C<T2 *, T>(_tl));
    4.10  
    4.11              return sa;
    4.12 @@ -300,8 +300,14 @@
    4.13              bloblist_t *_bl = bl;
    4.14              for (LONG i = lbound; i <= ubound; i++) {
    4.15                  blob b;
    4.16 +                memset(&b, 0, sizeof(blob));
    4.17                  SafeArrayGetElement(sa, &i, &b);
    4.18  
    4.19 +                LONG _lbound, _ubound;
    4.20 +                SafeArrayGetLBound(b.value, 1, &_lbound);
    4.21 +                SafeArrayGetUBound(b.value, 1, &_ubound);
    4.22 +                size_t size = _ubound - _lbound + 1;
    4.23 +
    4.24                  char *buffer = (char *) malloc(size);
    4.25                  if (buffer == NULL)
    4.26                      throw bad_alloc();
    4.27 @@ -312,7 +318,7 @@
    4.28                  memcpy(buffer, data, size);
    4.29                  SafeArrayUnaccessData(sa);
    4.30  
    4.31 -                _bl = bloblist_add(_bl, buffer, ubound - lbound + 1, str(b.mime_type), str(b.filename));
    4.32 +                _bl = bloblist_add(_bl, buffer, size, str(b.mime_type), str(b.filename));
    4.33                  if (_bl == NULL) {
    4.34                      IRecordInfo *ri = getRecordInfo<blob>();
    4.35                      ri->RecordClear(&b);
     5.1 --- a/utf8_helper.cpp	Sun May 31 17:03:40 2015 +0200
     5.2 +++ b/utf8_helper.cpp	Sun May 31 18:26:37 2015 +0200
     5.3 @@ -80,14 +80,16 @@
     5.4  
     5.5          CComSafeArray<BSTR> string_array(const ::stringlist_t *stringlist)
     5.6          {
     5.7 -            if (stringlist == NULL)
     5.8 +            int len = ::stringlist_length(stringlist);
     5.9 +
    5.10 +            if (len = 0)
    5.11                  return CComSafeArray<BSTR>((ULONG)0);
    5.12  
    5.13 -            CComSafeArray<BSTR> sa_string_list;
    5.14 -            int n = 0;
    5.15 -            for (const ::stringlist_t *k = stringlist; k != NULL; k = k->next) {
    5.16 +            CComSafeArray<BSTR> sa_string_list((LONG) len);
    5.17 +            LONG n = 0;
    5.18 +            for (const ::stringlist_t *k = stringlist; k && k->value; k = k->next) {
    5.19                  if (k->value) {
    5.20 -                    HRESULT _result = sa_string_list.Add(utf16_bstr(k->value).Detach(), false);
    5.21 +                    HRESULT _result = sa_string_list.SetAt(n, utf16_bstr(k->value).Detach(), false);
    5.22                      assert(_result == S_OK);
    5.23                      if (_result == E_OUTOFMEMORY)
    5.24                          throw std::bad_alloc();