From da12f9bb9e52a66915c9506c11b74967d94e2ece Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 19 May 2016 16:10:42 +0000 Subject: we don't try to cache NULL contact git-svn-id: http://svn.miranda-ng.org/main/trunk@16854 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/src/modern_clcitems.cpp | 3 +++ src/mir_app/src/clistsettings.cpp | 8 +++++++- src/mir_app/src/contacts.cpp | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp index 7bf3c4aff2..2440bbec89 100644 --- a/plugins/Clist_modern/src/modern_clcitems.cpp +++ b/plugins/Clist_modern/src/modern_clcitems.cpp @@ -516,6 +516,9 @@ ClcContact* cliCreateClcContact() ClcCacheEntry* cliCreateCacheItem(MCONTACT hContact) { + if (hContact == NULL) + return NULL; + ClcCacheEntry *pdnce = (ClcCacheEntry *)mir_calloc(sizeof(ClcCacheEntry)); if (pdnce == NULL) return NULL; diff --git a/src/mir_app/src/clistsettings.cpp b/src/mir_app/src/clistsettings.cpp index 54d36ca38f..0e245c4d63 100644 --- a/src/mir_app/src/clistsettings.cpp +++ b/src/mir_app/src/clistsettings.cpp @@ -41,6 +41,9 @@ void FreeDisplayNameCache(void) ClcCacheEntry* fnCreateCacheItem(MCONTACT hContact) { + if (hContact == NULL) + return NULL; + ClcCacheEntry *p = (ClcCacheEntry*)mir_calloc(sizeof(ClcCacheEntry)); if (p == NULL) return NULL; @@ -99,8 +102,10 @@ void fnInvalidateDisplayNameCacheEntry(MCONTACT hContact) TCHAR* fnGetContactDisplayName(MCONTACT hContact, int mode) { + if (hContact == NULL) + return TranslateT("(Unknown contact)"); + ClcCacheEntry *cacheEntry = NULL; - if (mode & GCDNF_NOCACHE) mode &= ~GCDNF_NOCACHE; else if (mode != GCDNF_NOMYHANDLE) { @@ -117,6 +122,7 @@ TCHAR* fnGetContactDisplayName(MCONTACT hContact, int mode) } CallContactService(hContact, PSS_GETINFO, SGIF_MINIMAL, 0); + TCHAR *buffer = TranslateT("(Unknown contact)"); return (cacheEntry == NULL) ? mir_tstrdup(buffer) : buffer; } diff --git a/src/mir_app/src/contacts.cpp b/src/mir_app/src/contacts.cpp index e2c679dcc3..5e6a6bc52b 100644 --- a/src/mir_app/src/contacts.cpp +++ b/src/mir_app/src/contacts.cpp @@ -87,6 +87,9 @@ static TCHAR* ProcessDatabaseValueDefault(MCONTACT hContact, const char *szProto MIR_APP_DLL(TCHAR*) Contact_GetInfo(int type, MCONTACT hContact, const char *szProto) { + if (hContact == NULL && szProto == NULL) + return NULL; + if (szProto == NULL) szProto = Proto_GetBaseAccountName(hContact); if (szProto == NULL) -- cgit v1.2.3