From 10b9fb4af872957d78b4d8fe41eb339f9cd386b6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 15 Jul 2023 19:19:17 +0300 Subject: Telegram: fix for occasional crash --- protocols/Telegram/src/avatars.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/protocols/Telegram/src/avatars.cpp b/protocols/Telegram/src/avatars.cpp index 433bda9e9f..22121ccabe 100644 --- a/protocols/Telegram/src/avatars.cpp +++ b/protocols/Telegram/src/avatars.cpp @@ -112,8 +112,7 @@ void __cdecl CTelegramProto::OfflineFileThread(void *pParam) SendQuery(new TD::getRemoteFile(root["u"].as_string(), 0), &CTelegramProto::OnGetFileInfo, ft); } } - - delete ofd; + else delete ofd; } INT_PTR __cdecl CTelegramProto::SvcOfflineFile(WPARAM param, LPARAM) @@ -158,12 +157,12 @@ void CTelegramProto::ProcessFile(TD::updateFile *pObj) Utf2T wszExistingFile(pFile->local_->path_.c_str()); if (auto *F = PopFile(pFile->remote_->unique_id_.c_str())) { - CMStringW wszFullName = F->m_destPath; - if (!wszFullName.IsEmpty()) - wszFullName += L"\\"; - wszFullName += F->m_fileName; - if (F->m_type == F->AVATAR) { + CMStringW wszFullName = F->m_destPath; + if (!wszFullName.IsEmpty()) + wszFullName += L"\\"; + wszFullName += F->m_fileName; + if (F->m_fileName.Right(5).MakeLower() == L".webp") { if (auto *pImage = FreeImage_LoadU(FIF_WEBP, wszExistingFile)) { wszFullName.Truncate(wszFullName.GetLength() - 5); @@ -188,6 +187,9 @@ void CTelegramProto::ProcessFile(TD::updateFile *pObj) db_event_setJson(F->ofd->hDbEvent, "ft", &dbv); db_event_setJson(F->ofd->hDbEvent, "fs", &dbv); + CMStringW wszFullName(F->ofd->wszPath); + + // let's replace fake file name with the real one if (F->m_type != F->FILE) { auto *pSlash = strrchr(pFile->local_->path_.c_str(), '\\'); if (!pSlash) -- cgit v1.2.3