From 478b3261723a914310271ece3ef91abc9ce2b4cc Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 15 Mar 2024 18:44:23 +0300 Subject: fixes #4214 ([Telegram] Crash) --- include/m_protoint.h | 2 +- libs/win32/mir_app.lib | Bin 292758 -> 292744 bytes libs/win64/mir_app.lib | Bin 292538 -> 292518 bytes protocols/ICQ-WIM/src/proto.cpp | 5 +++-- protocols/ICQ-WIM/src/proto.h | 2 +- protocols/ICQ-WIM/src/server.cpp | 2 +- protocols/JabberG/src/jabber_file.cpp | 5 +++-- protocols/JabberG/src/jabber_proto.h | 2 +- protocols/Telegram/src/avatars.cpp | 5 +++-- protocols/Telegram/src/proto.h | 2 +- protocols/Telegram/src/utils.cpp | 6 +----- src/mir_app/src/file.cpp | 2 +- src/mir_app/src/mir_app.def | 2 +- src/mir_app/src/mir_app64.def | 2 +- src/mir_app/src/proto_interface.cpp | 2 +- 15 files changed, 19 insertions(+), 20 deletions(-) diff --git a/include/m_protoint.h b/include/m_protoint.h index 444b64e64c..3b1b7fb4c3 100644 --- a/include/m_protoint.h +++ b/include/m_protoint.h @@ -284,7 +284,7 @@ public: virtual void OnModulesLoaded(void); // called when an cloud file is being received - virtual void OnReceiveOfflineFile(DB::FILE_BLOB &blob, void *ft); + virtual void OnReceiveOfflineFile(DB::FILE_BLOB &blob); // prepares an event of the file being sent virtual void OnSendOfflineFile(DB::EventInfo &dbei, DB::FILE_BLOB &blob, void *ft); diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib index 30ceb3cc3d..2a4b13eb39 100644 Binary files a/libs/win32/mir_app.lib and b/libs/win32/mir_app.lib differ diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib index 059d20b51c..5b60f97793 100644 Binary files a/libs/win64/mir_app.lib and b/libs/win64/mir_app.lib differ diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index 00f37bfa92..5c93aa0147 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -174,11 +174,12 @@ bool CIcqProto::OnContactDeleted(MCONTACT hContact, uint32_t flags) return true; } -void CIcqProto::OnReceiveOfflineFile(DB::FILE_BLOB &blob, void *ft) +void CIcqProto::OnReceiveOfflineFile(DB::FILE_BLOB &blob) { - if (auto *pFileInfo = (IcqFileInfo *)ft) { + if (auto *pFileInfo = (IcqFileInfo *)blob.getUserInfo()) { blob.setUrl(pFileInfo->szOrigUrl); blob.setSize(pFileInfo->dwFileSize); + delete pFileInfo; } } diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index 8416e344a7..514787102a 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -450,7 +450,7 @@ class CIcqProto : public PROTO void OnEventEdited(MCONTACT, MEVENT, const DBEVENTINFO &dbei) override; void OnMarkRead(MCONTACT, MEVENT) override; void OnModulesLoaded() override; - void OnReceiveOfflineFile(DB::FILE_BLOB &blob, void *ft) override; + void OnReceiveOfflineFile(DB::FILE_BLOB &blob) override; void OnSendOfflineFile(DB::EventInfo &dbei, DB::FILE_BLOB &blob, void *ft) override; void OnShutdown() override; diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 506b0651fb..5d758f6b11 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -616,7 +616,7 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo DB::FILE_BLOB blob(pFileInfo, pszShortName, T2Utf(pFileInfo->wszDescr)); if (hOldEvent) { - OnReceiveOfflineFile(blob, pFileInfo); + OnReceiveOfflineFile(blob); blob.write(dbei); db_event_edit(hOldEvent, &dbei, true); } diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index 51461785da..2a49b53d19 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -113,14 +113,15 @@ INT_PTR __cdecl CJabberProto::OnOfflineFile(WPARAM param, LPARAM) return 0; } -void CJabberProto::OnReceiveOfflineFile(DB::FILE_BLOB &blob, void *pHandle) +void CJabberProto::OnReceiveOfflineFile(DB::FILE_BLOB &blob) { - if (auto *ft = (filetransfer *)pHandle) { + if (auto *ft = (filetransfer *)blob.getUserInfo()) { if (ft->type == FT_HTTP) { if (ft->httpPath) blob.setUrl(ft->httpPath); blob.setSize(ft->dwExpectedRecvFileSize); } + delete ft; } } diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index c87874ec20..17fc45c80e 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -153,7 +153,7 @@ struct CJabberProto : public PROTO, public IJabberInterface MWindow OnCreateAccMgrUI(MWindow) override; void OnMarkRead(MCONTACT, MEVENT) override; void OnModulesLoaded() override; - void OnReceiveOfflineFile(DB::FILE_BLOB &blob, void *ft) override; + void OnReceiveOfflineFile(DB::FILE_BLOB &blob) override; void OnSendOfflineFile(DB::EventInfo &dbei, DB::FILE_BLOB &blob, void *ft) override; void OnShutdown() override; diff --git a/protocols/Telegram/src/avatars.cpp b/protocols/Telegram/src/avatars.cpp index ed6efbd3de..dcfa894ced 100644 --- a/protocols/Telegram/src/avatars.cpp +++ b/protocols/Telegram/src/avatars.cpp @@ -149,11 +149,12 @@ INT_PTR __cdecl CTelegramProto::SvcOfflineFile(WPARAM param, LPARAM) ///////////////////////////////////////////////////////////////////////////////////////// // Cloud file pre-creator -void CTelegramProto::OnReceiveOfflineFile(DB::FILE_BLOB &blob, void *pHandle) +void CTelegramProto::OnReceiveOfflineFile(DB::FILE_BLOB &blob) { - if (auto *ft = (TG_FILE_REQUEST *)pHandle) { + if (auto *ft = (TG_FILE_REQUEST *)blob.getUserInfo()) { blob.setUrl(ft->m_uniqueId.GetBuffer()); blob.setSize(ft->m_fileSize); + delete ft; } } diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index b4df98a636..141a2d3034 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -384,7 +384,7 @@ public: void OnEventEdited(MCONTACT, MEVENT, const DBEVENTINFO &dbei) override; void OnMarkRead(MCONTACT, MEVENT) override; void OnModulesLoaded() override; - void OnReceiveOfflineFile(DB::FILE_BLOB &blob, void *ft) override; + void OnReceiveOfflineFile(DB::FILE_BLOB &blob) override; void OnSendOfflineFile(DB::EventInfo &dbei, DB::FILE_BLOB &blob, void *hTransfer) override; void OnShutdown() override; diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index ef19a92d3e..71a17bd3b6 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -403,10 +403,6 @@ bool CTelegramProto::GetMessageFile( pRequest->m_fileSize = pFile->size_; pRequest->m_bRecv = !pMsg->is_outgoing_; pRequest->m_hContact = GetRealContact(pUser); - { - mir_cslock lck(m_csFiles); - m_arFiles.insert(pRequest); - } char szReplyId[100]; const char *szDesc = nullptr; @@ -430,7 +426,7 @@ bool CTelegramProto::GetMessageFile( if (dbei) { DB::FILE_BLOB blob(dbei); - OnReceiveOfflineFile(blob, pRequest); + OnReceiveOfflineFile(blob); blob.write(dbei); db_event_edit(hDbEvent, &dbei, true); delete pRequest; diff --git a/src/mir_app/src/file.cpp b/src/mir_app/src/file.cpp index ca76162356..b57983de1b 100644 --- a/src/mir_app/src/file.cpp +++ b/src/mir_app/src/file.cpp @@ -227,7 +227,7 @@ MEVENT Proto_RecvFile(MCONTACT hContact, DB::FILE_BLOB &blob, DB::EventInfo &dbe CMStringW wszFiles, wszDescr; if (auto *ppro = Proto_GetContactInstance(hContact)) - ppro->OnReceiveOfflineFile(blob, blob.getUserInfo()); + ppro->OnReceiveOfflineFile(blob); blob.write(dbei); MEVENT hdbe = db_event_add(hContact, &dbei); diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index e76bce77d3..55df94ce86 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -851,7 +851,7 @@ Chat_IsMuted @941 NONAME ?getIcon@LOGINFO@@QBEHXZ @981 NONAME ?getIndex@LOGINFO@@QBEHXZ @982 NONAME ?write@LOGINFO@@QBEXPAURtfChatLogStreamData@@_NAAV?$CMStringT@DV?$ChTraitsCRT@D@@@@PB_W@Z @983 NONAME -?OnReceiveOfflineFile@PROTO_INTERFACE@@UAEXAAVFILE_BLOB@DB@@PAX@Z @984 NONAME +?OnReceiveOfflineFile@PROTO_INTERFACE@@UAEXAAVFILE_BLOB@DB@@@Z @984 NONAME ?setSize@FILE_BLOB@DB@@QAEX_J@Z @985 NONAME ?setUrl@FILE_BLOB@DB@@QAEXPBD@Z @986 NONAME ?Clist_GetEvent@@YGPAUCListEvent@@IH@Z @987 NONAME diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index e2f633c5e8..bf3e4e9d50 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -851,7 +851,7 @@ Chat_IsMuted @941 NONAME ?getIcon@LOGINFO@@QEBAHXZ @981 NONAME ?getIndex@LOGINFO@@QEBAHXZ @982 NONAME ?write@LOGINFO@@QEBAXPEAURtfChatLogStreamData@@_NAEAV?$CMStringT@DV?$ChTraitsCRT@D@@@@PEB_W@Z @983 NONAME -?OnReceiveOfflineFile@PROTO_INTERFACE@@UEAAXAEAVFILE_BLOB@DB@@PEAX@Z @984 NONAME +?OnReceiveOfflineFile@PROTO_INTERFACE@@UEAAXAEAVFILE_BLOB@DB@@@Z @984 NONAME ?setSize@FILE_BLOB@DB@@QEAAX_J@Z @985 NONAME ?setUrl@FILE_BLOB@DB@@QEAAXPEBD@Z @986 NONAME ?Clist_GetEvent@@YAPEAUCListEvent@@IH@Z @987 NONAME diff --git a/src/mir_app/src/proto_interface.cpp b/src/mir_app/src/proto_interface.cpp index 8aabb11acd..a6fa43f410 100644 --- a/src/mir_app/src/proto_interface.cpp +++ b/src/mir_app/src/proto_interface.cpp @@ -102,7 +102,7 @@ bool PROTO_INTERFACE::IsReadyToExit() return true; } -void PROTO_INTERFACE::OnReceiveOfflineFile(DB::FILE_BLOB &, void *) +void PROTO_INTERFACE::OnReceiveOfflineFile(DB::FILE_BLOB &) {} void PROTO_INTERFACE::OnSendOfflineFile(DB::EventInfo &, DB::FILE_BLOB &, void *) -- cgit v1.2.3