summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/modules/protocols/protochains.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/modules/protocols/protochains.cpp b/src/modules/protocols/protochains.cpp
index 977ba9090c..3e86014fed 100644
--- a/src/modules/protocols/protochains.cpp
+++ b/src/modules/protocols/protochains.cpp
@@ -32,9 +32,7 @@ static int GetProtocolP(HANDLE hContact, char *szBuf, int cbLen)
return 1;
DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
- if (cc == NULL)
- cc = currDb->m_cache->AddContactToCache(hContact);
- if (cc->szProto != NULL) {
+ if (cc && cc->szProto != NULL) {
strncpy(szBuf, cc->szProto, cbLen);
szBuf[cbLen-1] = 0;
return 0;
@@ -51,8 +49,12 @@ static int GetProtocolP(HANDLE hContact, char *szBuf, int cbLen)
dbcgs.szSetting = "p";
int res = currDb->GetContactSettingStatic(hContact, &dbcgs);
- if (res == 0 && !cc->szProto)
+ if (res == 0) {
+ if (cc == NULL)
+ cc = currDb->m_cache->AddContactToCache(hContact);
+
cc->szProto = currDb->m_cache->GetCachedSetting(NULL, szBuf, 0, strlen(szBuf));
+ }
return res;
}