diff options
author | George Hazan <george.hazan@gmail.com> | 2023-07-15 19:19:17 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-07-15 19:19:17 +0300 |
commit | 10b9fb4af872957d78b4d8fe41eb339f9cd386b6 (patch) | |
tree | 51f1c5feebc608b5639c0ea1098ae60b2fc433fb /protocols | |
parent | aaa9949ab7164947699377d3cef239523e8e5681 (diff) |
Telegram: fix for occasional crash
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Telegram/src/avatars.cpp | 16 |
1 files 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)
|