diff options
author | George Hazan <ghazan@miranda.im> | 2021-06-05 17:50:34 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-06-05 17:50:34 +0300 |
commit | d7c9eb34f80f207efd47d2fc65e31aedf166c323 (patch) | |
tree | 338b9b905674dc31b1efab739dfcedeed3d8d7b3 /protocols/SkypeWeb/src | |
parent | ffc5a3d7550528281976745279e77ac9faba551b (diff) |
major code cleaning in regard to db_event_getBlobSize & event memory allocation
Diffstat (limited to 'protocols/SkypeWeb/src')
-rw-r--r-- | protocols/SkypeWeb/src/skype_db.cpp | 10 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_proto.cpp | 12 |
2 files changed, 9 insertions, 13 deletions
diff --git a/protocols/SkypeWeb/src/skype_db.cpp b/protocols/SkypeWeb/src/skype_db.cpp index 0dc8e8ce8b..e8ac1ab738 100644 --- a/protocols/SkypeWeb/src/skype_db.cpp +++ b/protocols/SkypeWeb/src/skype_db.cpp @@ -58,11 +58,11 @@ MEVENT CSkypeProto::AddDbEvent(WORD type, MCONTACT hContact, DWORD timestamp, DW void CSkypeProto::EditEvent(MCONTACT hContact, MEVENT hEvent, const CMStringW &szContent, time_t edit_time) { mir_cslock lck(m_AppendMessageLock); - DBEVENTINFO dbei = {}; - dbei.cbBlob = db_event_getBlobSize(hEvent); - mir_ptr<BYTE> blob((PBYTE)mir_alloc(dbei.cbBlob)); - dbei.pBlob = blob; - db_event_get(hEvent, &dbei); + + DB::EventInfo dbei; + dbei.cbBlob = -1; + if (db_event_get(hEvent, &dbei)) + return; JSONNode jMsg = JSONNode::parse((char*)dbei.pBlob); if (jMsg) { diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp index f5cc5f5bd9..6bc6e8e66e 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -192,11 +192,9 @@ MCONTACT CSkypeProto::AddToList(int, PROTOSEARCHRESULT *psr) MCONTACT CSkypeProto::AddToListByEvent(int, int, MEVENT hDbEvent) { debugLogA(__FUNCTION__); - DBEVENTINFO dbei = {}; - if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1)) - return NULL; - if ((dbei.pBlob = (PBYTE)alloca(dbei.cbBlob)) == nullptr) - return NULL; + + DB::EventInfo dbei; + dbei.cbBlob = -1; if (db_event_get(hDbEvent, &dbei)) return NULL; if (mir_strcmp(dbei.szModule, m_szModuleName)) @@ -205,9 +203,7 @@ MCONTACT CSkypeProto::AddToListByEvent(int, int, MEVENT hDbEvent) return NULL; DB::AUTH_BLOB blob(dbei.pBlob); - - MCONTACT hContact = AddContact(blob.get_email(), blob.get_nick()); - return hContact; + return AddContact(blob.get_email(), blob.get_nick()); } int CSkypeProto::Authorize(MEVENT hDbEvent) |