summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-05-21 20:06:49 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-05-21 20:06:49 +0300
commite8d2b998009a1912988a74e56d37338fd7b94967 (patch)
treedc5560068c8ce7e335288aeefbfd0030b567c4df /src
parent2b430b7ac974fe029babe18990656af3e917182c (diff)
fix for eternal loop caused by embedded array item deletion
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/clistevents.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/mir_app/src/clistevents.cpp b/src/mir_app/src/clistevents.cpp
index b7b88f6faf..b37dede347 100644
--- a/src/mir_app/src/clistevents.cpp
+++ b/src/mir_app/src/clistevents.cpp
@@ -293,12 +293,13 @@ MIR_APP_DLL(CListEvent *) Clist_GetEvent(MCONTACT hContact, int idx)
int EventsProcessContactDoubleClick(MCONTACT hContact)
{
- for (auto &it : g_cliEvents) {
- if (it->hContact == hContact) {
- CallService(it->pszService, 0, (LPARAM)it);
- g_clistApi.pfnFreeEvent(it);
- return 0;
- }
+ if (auto *pEvent = Clist_GetEvent(hContact, 0)) {
+ CallService(pEvent->pszService, 0, (LPARAM)pEvent);
+
+ // if the event is still alive, free it
+ if (g_cliEvents.indexOf(pEvent))
+ g_clistApi.pfnFreeEvent(pEvent);
+ return 0;
}
return 1;