From 2cd05c2649104e8690defdcf0122d8c3e827c1d2 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Sat, 10 Jan 2015 18:44:06 +0000 Subject: Variables: - Fixed various memory leaks git-svn-id: http://svn.miranda-ng.org/main/trunk@11821 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Variables/src/contact.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'plugins/Variables/src/contact.cpp') diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp index 65a92523e4..b5258b422f 100644 --- a/plugins/Variables/src/contact.cpp +++ b/plugins/Variables/src/contact.cpp @@ -107,10 +107,6 @@ BYTE getContactInfoType(TCHAR* type) TCHAR* getContactInfoT(BYTE type, MCONTACT hContact) { /* returns dynamic allocated buffer with info, or NULL if failed */ - TCHAR *res = NULL; - char protoname[128], szVal[16]; - PROTOACCOUNT *pa; - if (hContact == NULL) return NULL; @@ -118,18 +114,22 @@ TCHAR* getContactInfoT(BYTE type, MCONTACT hContact) if (szProto == NULL) return NULL; + TCHAR *res = NULL; switch (type) { case CCNF_PROTOID: return mir_a2t(szProto); - case CCNF_ACCOUNT: - pa = ProtoGetAccount(szProto); + case CCNF_ACCOUNT: { + PROTOACCOUNT *pa = ProtoGetAccount(szProto); return pa ? mir_tstrdup(pa->tszAccountName) : NULL; + } - case CCNF_PROTOCOL: + case CCNF_PROTOCOL: { + char protoname[128]; if (CallProtoService(szProto, PS_GETNAME, (WPARAM)sizeof(protoname), (LPARAM)protoname)) return NULL; return mir_a2t(protoname); + } case CCNF_STATUS: return mir_tstrdup((TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE), GSMDF_UNICODE)); @@ -165,7 +165,8 @@ TCHAR* getContactInfoT(BYTE type, MCONTACT hContact) ci.hContact = hContact; ci.dwFlag = type | CNF_UNICODE; CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci); - + + char szVal[16]; memset(szVal, '\0', sizeof(szVal)); switch(ci.type) { case CNFT_BYTE: @@ -334,7 +335,7 @@ int getContactFromString(CONTACTSINFO *ci) return -1; ci->hContacts[count] = hContact; - count += 1; + count++; } } @@ -346,7 +347,7 @@ int getContactFromString(CONTACTSINFO *ci) cce[cacheSize].flags = ci->flags; cce[cacheSize].tszContact = mir_tstrdup(tszContact); if (cce[cacheSize].tszContact != NULL) - cacheSize += 1; + cacheSize++; } } -- cgit v1.2.3