From 799519203a9a94d711f580c9c50a5d73466bdde6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 24 Mar 2023 20:42:20 +0300 Subject: fixes #3452 (ICQ: crash on ProcessBuddyList) --- protocols/ICQ-WIM/src/poll.cpp | 1 + protocols/ICQ-WIM/src/proto.cpp | 4 +++- protocols/ICQ-WIM/src/utils.cpp | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'protocols/ICQ-WIM/src') diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp index 9b1e5aae92..c507c3babb 100644 --- a/protocols/ICQ-WIM/src/poll.cpp +++ b/protocols/ICQ-WIM/src/poll.cpp @@ -69,6 +69,7 @@ void CIcqProto::ProcessBuddyList(const JSONNode &ev) if (bEnableMenu) Menu_ShowItem(m_hUploadGroups, true); + mir_cslock lck(m_csCache); for (auto &it : m_arCache) if (!it->m_bInList && !getBool(it->m_hContact, "IcqDeleted")) Contact::RemoveFromList(it->m_hContact); diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index 1e6ffb5ada..8ee9b60d8b 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -154,8 +154,10 @@ void CIcqProto::OnContactAdded(MCONTACT hContact) void CIcqProto::OnContactDeleted(MCONTACT hContact) { CMStringW szId(GetUserId(hContact)); - if (!isChatRoom(hContact)) + if (!isChatRoom(hContact)) { + mir_cslock lck(m_csCache); m_arCache.remove(FindUser(szId)); + } Push(new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/buddylist/removeBuddy") << AIMSID(this) << WCHAR_PARAM("buddy", szId) << INT_PARAM("allGroups", 1)); diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp index bdaac877bf..83d876adb0 100644 --- a/protocols/ICQ-WIM/src/utils.cpp +++ b/protocols/ICQ-WIM/src/utils.cpp @@ -46,6 +46,8 @@ void CIcqProto::InitContactCache() auto *pUser = FindUser(wszId); if (pUser == nullptr) { pUser = new IcqUser(wszId, it); + + mir_cslock lck(m_csCache); m_arCache.insert(pUser); } pUser->m_iProcessedMsgId = getId(it, DB_KEY_LASTMSGID); -- cgit v1.2.3