diff options
author | George Hazan <george.hazan@gmail.com> | 2023-06-18 21:51:30 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-06-18 21:51:30 +0300 |
commit | e503f800768d5d794ca033a89f92e5b21d7eeee3 (patch) | |
tree | e4272bc0d09e0429ddcd4ce47f104353148c15f3 | |
parent | 8f5c72980a4511dd125cfcfe2038dfea8294e9e1 (diff) |
fixes #3561 (random crash inside chat engine)
-rw-r--r-- | include/m_chat_int.h | 3 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h index f23cce8e43..9eb1b989bb 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -168,9 +168,10 @@ struct MIR_APP_EXPORT SESSION_INFO : public MZeroedObject, public MNonCopyable uint16_t wCommandsNum;
void* pItemData;
time_t LastTime;
+ mir_cs csLock;
CMsgDialog *pDlg;
- USERINFO *pMe;
+ USERINFO *pMe;
STATUSINFO *pStatuses;
MODULEINFO *pMI;
SESSION_INFO *pParent;
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index b0c4999d89..ea74717a14 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -226,6 +226,7 @@ BOOL SM_RemoveUser(SESSION_INFO *si, const wchar_t *pszUID) if (!si || !pszUID)
return FALSE;
+ mir_cslock lck(si->csLock);
USERINFO *ui = UM_FindUser(si, pszUID);
if (!ui)
return FALSE;
@@ -586,6 +587,7 @@ static USERINFO* UM_FindUser(SESSION_INFO *si, const wchar_t *pszUID) if (!si || !pszUID)
return nullptr;
+ mir_cslock lck(si->csLock);
USERINFO tmp;
tmp.pszUID = (wchar_t*)pszUID;
return si->getKeyList().find(&tmp);
@@ -619,9 +621,10 @@ void UM_SortUser(SESSION_INFO *si) USERINFO* UM_AddUser(SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *pszNick, uint16_t wStatus)
{
- if (pszNick == nullptr)
+ if (!si || !pszUID || !pszNick)
return nullptr;
+ mir_cslock lck(si->csLock);
auto *pUser = UM_FindUser(si, pszUID);
if (pUser == nullptr) {
pUser = new USERINFO();
|