diff options
-rw-r--r-- | plugins/Variables/src/contact.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp index 3df3681d85..42a9357bde 100644 --- a/plugins/Variables/src/contact.cpp +++ b/plugins/Variables/src/contact.cpp @@ -178,10 +178,12 @@ MCONTACT getContactFromString(const wchar_t *tszContact, DWORD dwFlags, int nMat if (dwFlags & CI_NEEDCOUNT) {
dwFlags &= ~CI_NEEDCOUNT;
bReturnCount = true;
+ nMatch = -2;
}
else bReturnCount = false;
// search the cache
+ if (nMatch == 0)
{
CONTACTCE tmp = { dwFlags, (wchar_t*)tszContact, 0 };
@@ -279,13 +281,13 @@ MCONTACT getContactFromString(const wchar_t *tszContact, DWORD dwFlags, int nMat if (bReturnCount)
return count;
- if (hMatch == 0)
- return INVALID_CONTACT_ID;
-
// return random contact
- if (nMatch == -1)
+ if (nMatch == -1 && arResults.getCount() != 0)
return (UINT_PTR)arResults[rand() % arResults.getCount()];
+ if (hMatch == 0)
+ return INVALID_CONTACT_ID;
+
// cache the found result
if (count == 0) {
mir_cslock lck(csContactCache);
|