summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/TabSRMM/src/chat/manager.cpp3
-rw-r--r--protocols/WhatsApp/src/chat.cpp13
-rw-r--r--src/modules/chat/manager.cpp2
3 files changed, 13 insertions, 5 deletions
diff --git a/plugins/TabSRMM/src/chat/manager.cpp b/plugins/TabSRMM/src/chat/manager.cpp
index 01308537b1..0c8302e101 100644
--- a/plugins/TabSRMM/src/chat/manager.cpp
+++ b/plugins/TabSRMM/src/chat/manager.cpp
@@ -28,6 +28,9 @@
static int sttCompareNicknames(const TCHAR *s1, const TCHAR *s2)
{
+ if (s2 == NULL)
+ return 1;
+
// skip rubbish
while (*s1 && !_istalpha(*s1)) ++s1;
while (*s2 && !_istalpha(*s2)) ++s2;
diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp
index d6c650ec9d..a5be1e9bac 100644
--- a/protocols/WhatsApp/src/chat.cpp
+++ b/protocols/WhatsApp/src/chat.cpp
@@ -327,11 +327,16 @@ WAChatInfo* WhatsAppProto::InitChat(const std::string &jid, const std::string &n
TCHAR* WhatsAppProto::GetChatUserNick(const std::string &jid)
{
- if (m_szJid == jid)
- return str2t(m_szNick);
+ TCHAR* tszNick;
+ if (m_szJid != jid) {
+ MCONTACT hContact = ContactIDToHContact(jid);
+ tszNick = (hContact == 0) ? utils::removeA(str2t(jid)) : mir_tstrdup(pcli->pfnGetContactDisplayName(hContact, 0));
+ }
+ else tszNick = str2t(m_szNick);
- MCONTACT hContact = ContactIDToHContact(jid);
- return (hContact == 0) ? utils::removeA(str2t(jid)) : mir_tstrdup(pcli->pfnGetContactDisplayName(hContact, 0));
+ if (tszNick == NULL)
+ tszNick = mir_tstrdup(TranslateT("Unknown user"));
+ return tszNick;
}
WAChatInfo* WhatsAppProto::SafeGetChat(const std::string &jid)
diff --git a/src/modules/chat/manager.cpp b/src/modules/chat/manager.cpp
index c3706062de..7f59dd5f36 100644
--- a/src/modules/chat/manager.cpp
+++ b/src/modules/chat/manager.cpp
@@ -947,7 +947,7 @@ static USERINFO* UM_SortUser(USERINFO **ppUserList, const TCHAR *pszUID)
USERINFO* UM_AddUser(STATUSINFO *pStatusList, USERINFO **ppUserList, const TCHAR *pszUID, const TCHAR *pszNick, WORD wStatus)
{
- if (!pStatusList || !ppUserList)
+ if (pStatusList == NULL || ppUserList == NULL || pszNick == NULL)
return NULL;
USERINFO *ui = *ppUserList, *pLast = NULL;