From d6738c3c5796bd7f0def65eb7b3236bbf6d8373e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 11 Aug 2013 14:08:24 +0000 Subject: trap #2 for a crash git-svn-id: http://svn.miranda-ng.org/main/trunk@5652 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/chat.h | 2 +- plugins/TabSRMM/src/chat/manager.cpp | 40 ++++++++++++------------------------ 2 files changed, 14 insertions(+), 28 deletions(-) (limited to 'plugins/TabSRMM') diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h index f64b71728c..38ca3e9bd9 100644 --- a/plugins/TabSRMM/src/chat/chat.h +++ b/plugins/TabSRMM/src/chat/chat.h @@ -154,7 +154,7 @@ struct STATUSINFO { TCHAR *pszGroup; HICON hIcon; - WORD Status; + DWORD Status; STATUSINFO *next; }; diff --git a/plugins/TabSRMM/src/chat/manager.cpp b/plugins/TabSRMM/src/chat/manager.cpp index fcb5daf808..8171ea2dcc 100644 --- a/plugins/TabSRMM/src/chat/manager.cpp +++ b/plugins/TabSRMM/src/chat/manager.cpp @@ -751,7 +751,6 @@ SESSION_INFO* SM_FindSessionByIndex(const char* pszModule, int iItem) } return NULL; - } SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent) @@ -903,8 +902,7 @@ STATUSINFO * TM_AddStatus(STATUSINFO** ppStatusList, const TCHAR* pszStatus, int return NULL; if (!TM_FindStatus(*ppStatusList, pszStatus)) { - STATUSINFO *node = (STATUSINFO*) mir_alloc(sizeof(STATUSINFO)); - ZeroMemory(node, sizeof(STATUSINFO)); + STATUSINFO *node = (STATUSINFO*)mir_calloc(sizeof(STATUSINFO)); replaceStrT(node->pszGroup, pszStatus); node->hIcon = (HICON)(*iCount); while ((int)node->hIcon > STATUSICONCOUNT - 1) @@ -927,60 +925,48 @@ STATUSINFO * TM_AddStatus(STATUSINFO** ppStatusList, const TCHAR* pszStatus, int STATUSINFO * TM_FindStatus(STATUSINFO* pStatusList, const TCHAR* pszStatus) { - STATUSINFO *pTemp = pStatusList; - if (!pStatusList || !pszStatus) return NULL; - while (pTemp != NULL) { - if (lstrcmpi(pTemp->pszGroup, pszStatus) == 0) - return pTemp; + for (STATUSINFO *si = pStatusList; si != NULL; si = si->next) + if (lstrcmpi(si->pszGroup, pszStatus) == 0) + return si; - pTemp = pTemp->next; - } return 0; } WORD TM_StringToWord(STATUSINFO* pStatusList, const TCHAR* pszStatus) { - STATUSINFO *pTemp = pStatusList; - if (!pStatusList || !pszStatus) return 0; - while (pTemp != NULL) { - if (lstrcmpi(pTemp->pszGroup, pszStatus) == 0) - return pTemp->Status; + for (STATUSINFO *si = pStatusList; si != NULL; si = si->next) { + if (lstrcmpi(si->pszGroup, pszStatus) == 0) + return si->Status; - if (pTemp->next == NULL) + if (si->next == NULL) return pStatusList->Status; - - pTemp = pTemp->next; } return 0; } TCHAR* TM_WordToString(STATUSINFO* pStatusList, WORD Status) { - STATUSINFO *pTemp = pStatusList; - if (!pStatusList) return NULL; - while (pTemp != NULL) { - if (pTemp->Status&Status) { - Status -= pTemp->Status; + for (STATUSINFO *si = pStatusList; si != NULL; si = si->next) + if (si->Status&Status) { + Status -= si->Status; if (Status == 0) - return pTemp->pszGroup; + return si->pszGroup; } - pTemp = pTemp->next; - } + return 0; } BOOL TM_RemoveAll(STATUSINFO** ppStatusList) { - if (!ppStatusList) return FALSE; -- cgit v1.2.3