Detach() first
parent
8f16384aef
commit
b6b3122952
|
@ -117,11 +117,11 @@ STDMETHODIMP CpEpEngine::decrypt(BSTR ctext, BSTR * ptext, LPSAFEARRAY * key_lis
|
|||
return FAIL(L"cannot decrypt");
|
||||
}
|
||||
|
||||
*ptext = utf16_bstr(_ptext).Detach();
|
||||
*ptext = utf16_bstr(_ptext);
|
||||
pEp_free(_ptext);
|
||||
|
||||
if (_keylist && _keylist->value)
|
||||
*key_list = string_array(_keylist).Detach();
|
||||
*key_list = string_array(_keylist);
|
||||
else
|
||||
*key_list = NULL;
|
||||
::free_stringlist(_keylist);
|
||||
|
@ -196,7 +196,7 @@ STDMETHODIMP CpEpEngine::decrypt_b(BSTR ctext, LPSAFEARRAY * ptext, LPSAFEARRAY
|
|||
::pEp_free(_ptext);
|
||||
|
||||
if (_keylist && _keylist->value)
|
||||
*key_list = string_array(_keylist).Detach();
|
||||
*key_list = string_array(_keylist);
|
||||
else
|
||||
*key_list = NULL;
|
||||
::free_stringlist(_keylist);
|
||||
|
@ -228,7 +228,7 @@ STDMETHODIMP CpEpEngine::verify(BSTR text, BSTR signature, LPSAFEARRAY * key_lis
|
|||
*verify_status = (pEp_STATUS) _status;
|
||||
|
||||
if (_keylist && _keylist->value)
|
||||
*key_list = string_array(_keylist).Detach();
|
||||
*key_list = string_array(_keylist);
|
||||
else
|
||||
*key_list = NULL;
|
||||
::free_stringlist(_keylist);
|
||||
|
@ -271,7 +271,7 @@ STDMETHODIMP CpEpEngine::encrypt(SAFEARRAY * key_list, BSTR ptext, BSTR * ctext,
|
|||
if (_ctext == NULL)
|
||||
return FAIL(L"encrypt_and_sign");
|
||||
|
||||
*ctext = utf16_bstr(_ctext).Detach();
|
||||
*ctext = utf16_bstr(_ctext);
|
||||
pEp_free(_ctext);
|
||||
|
||||
return S_OK;
|
||||
|
@ -367,7 +367,7 @@ STDMETHODIMP CpEpEngine::trustword(LONG value, BSTR lang, BSTR * word)
|
|||
return FAIL(L"trustword");
|
||||
}
|
||||
else {
|
||||
*word = utf16_bstr(_word).Detach();
|
||||
*word = utf16_bstr(_word);
|
||||
pEp_free(_word);
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ STDMETHODIMP CpEpEngine::trustwords(BSTR fpr, BSTR lang, LONG max_words, BSTR *
|
|||
return FAIL(L"trustwords");
|
||||
}
|
||||
else {
|
||||
*words = utf16_bstr(_words).Detach();
|
||||
*words = utf16_bstr(_words);
|
||||
pEp_free(_words);
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ STDMETHODIMP CpEpEngine::generate_keypair(pEp_identity_s * ident, BSTR * fpr)
|
|||
}
|
||||
|
||||
if (_ident->fpr)
|
||||
*fpr = utf16_bstr(_ident->fpr).Detach();
|
||||
*fpr = utf16_bstr(_ident->fpr);
|
||||
|
||||
::free_identity(_ident);
|
||||
|
||||
|
@ -635,7 +635,7 @@ STDMETHODIMP CpEpEngine::find_keys(BSTR pattern, LPSAFEARRAY * key_list)
|
|||
return FAIL(L"find_keys");
|
||||
|
||||
if (_keylist && _keylist->value) {
|
||||
*key_list = string_array(_keylist).Detach();
|
||||
*key_list = string_array(_keylist);
|
||||
}
|
||||
else {
|
||||
::free_stringlist(_keylist);
|
||||
|
@ -898,6 +898,8 @@ STDMETHODIMP CpEpEngine::decrypt_message(text_message * src, text_message * dst,
|
|||
assert(keylist);
|
||||
assert(rating);
|
||||
|
||||
*keylist = NULL;
|
||||
|
||||
::message *_src = text_message_to_C(src);
|
||||
::message *msg_dst = NULL;
|
||||
::stringlist_t *_keylist;
|
||||
|
@ -912,7 +914,7 @@ STDMETHODIMP CpEpEngine::decrypt_message(text_message * src, text_message * dst,
|
|||
}
|
||||
|
||||
if (_keylist) {
|
||||
*keylist = string_array(_keylist).Detach();
|
||||
*keylist = string_array(_keylist);
|
||||
free_stringlist(_keylist);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,12 +63,12 @@ namespace pEp {
|
|||
if (_ident == NULL)
|
||||
throw bad_alloc();
|
||||
|
||||
_ident->address = utf16_bstr(this->address).Detach();
|
||||
_ident->address = utf16_bstr(this->address);
|
||||
_ident->comm_type = this->comm_type;
|
||||
_ident->fpr = utf16_bstr(this->fpr).Detach();
|
||||
_ident->lang = utf16_bstr(this->lang).Detach();
|
||||
_ident->username = utf16_bstr(this->username).Detach();
|
||||
_ident->user_id = utf16_bstr(this->user_id).Detach();
|
||||
_ident->fpr = utf16_bstr(this->fpr);
|
||||
_ident->lang = utf16_bstr(this->lang);
|
||||
_ident->username = utf16_bstr(this->username);
|
||||
_ident->user_id = utf16_bstr(this->user_id);
|
||||
|
||||
return _ident;
|
||||
}
|
||||
|
@ -80,16 +80,16 @@ namespace pEp {
|
|||
::memset(ident_s, 0, sizeof(pEp_identity_s));
|
||||
if (ident) {
|
||||
if (ident->address)
|
||||
ident_s->address = utf16_bstr(ident->address).Detach();
|
||||
ident_s->address = utf16_bstr(ident->address);
|
||||
if (ident->fpr)
|
||||
ident_s->fpr = utf16_bstr(ident->fpr).Detach();
|
||||
ident_s->fpr = utf16_bstr(ident->fpr);
|
||||
if (ident->user_id)
|
||||
ident_s->user_id = utf16_bstr(ident->user_id).Detach();
|
||||
ident_s->user_id = utf16_bstr(ident->user_id);
|
||||
if (ident->username)
|
||||
ident_s->username = utf16_bstr(ident->username).Detach();
|
||||
ident_s->username = utf16_bstr(ident->username);
|
||||
ident_s->comm_type = (pEp_comm_type) ident->comm_type;
|
||||
if (ident->lang)
|
||||
ident_s->lang = utf16_bstr(ident->lang).Detach();
|
||||
ident_s->lang = utf16_bstr(ident->lang);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ namespace pEp {
|
|||
template<> BSTR from_C< BSTR, char >(char *s)
|
||||
{
|
||||
if (s)
|
||||
return utf16_bstr(s).Detach();
|
||||
return utf16_bstr(s);
|
||||
else
|
||||
return _bstr_t(L"").Detach();
|
||||
}
|
||||
|
@ -273,8 +273,8 @@ namespace pEp {
|
|||
msg2->cc = array_from_C<pEp_identity_s, identity_list>(msg->cc);
|
||||
msg2->bcc = array_from_C<pEp_identity_s, identity_list>(msg->bcc);
|
||||
msg2->reply_to = array_from_C<pEp_identity_s, identity_list>(msg->reply_to);
|
||||
msg2->references = string_array(msg->references).Detach();
|
||||
msg2->keywords = string_array(msg->keywords).Detach();
|
||||
msg2->references = string_array(msg->references);
|
||||
msg2->keywords = string_array(msg->keywords);
|
||||
msg2->comments = bstr(msg->comments);
|
||||
msg2->opt_fields = array_from_C<opt_field, stringpair_list_t>(msg->opt_fields);
|
||||
}
|
||||
|
|
|
@ -73,24 +73,24 @@ namespace pEp {
|
|||
return result;
|
||||
}
|
||||
|
||||
_bstr_t utf16_bstr(string str)
|
||||
BSTR utf16_bstr(string str)
|
||||
{
|
||||
wstring wstr = utf16_string(str);
|
||||
return _bstr_t(wstr.c_str());
|
||||
return _bstr_t(wstr.c_str()).Detach();
|
||||
}
|
||||
|
||||
CComSafeArray<BSTR> string_array(const ::stringlist_t *stringlist)
|
||||
LPSAFEARRAY string_array(const ::stringlist_t *stringlist)
|
||||
{
|
||||
int len = ::stringlist_length(stringlist);
|
||||
|
||||
if (len = 0)
|
||||
return CComSafeArray<BSTR>((ULONG)0);
|
||||
return NULL;
|
||||
|
||||
CComSafeArray<BSTR> sa_string_list((LONG) len);
|
||||
LONG n = 0;
|
||||
for (const ::stringlist_t *k = stringlist; k && k->value; k = k->next) {
|
||||
if (k->value) {
|
||||
HRESULT _result = sa_string_list.SetAt(n, utf16_bstr(k->value).Detach(), false);
|
||||
HRESULT _result = sa_string_list.SetAt(n, utf16_bstr(k->value), false);
|
||||
assert(_result == S_OK);
|
||||
if (_result == E_OUTOFMEMORY)
|
||||
throw std::bad_alloc();
|
||||
|
@ -98,7 +98,7 @@ namespace pEp {
|
|||
}
|
||||
}
|
||||
|
||||
return sa_string_list;
|
||||
return sa_string_list.Detach();
|
||||
}
|
||||
|
||||
::stringlist_t * new_stringlist(const SAFEARRAY * safearray)
|
||||
|
|
|
@ -6,8 +6,8 @@ namespace pEp {
|
|||
std::string utf8_string(std::wstring wstr, NORM_FORM norm = NormalizationC);
|
||||
std::string utf8_string(BSTR bstr, NORM_FORM norm = NormalizationC);
|
||||
std::wstring utf16_string(std::string str);
|
||||
_bstr_t utf16_bstr(std::string str);
|
||||
ATL::CComSafeArray<BSTR> string_array(const ::stringlist_t *stringlist);
|
||||
BSTR utf16_bstr(std::string str);
|
||||
LPSAFEARRAY string_array(const ::stringlist_t *stringlist);
|
||||
::stringlist_t * new_stringlist(const SAFEARRAY * safearray);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue