summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-09-20 18:16:08 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-09-20 18:16:08 +0000
commitdb3809c5db0a3a1bf82ecd59a5523e8831c207dd (patch)
tree92e0672b666b94c12bf44499446e134efbb302d9 /plugins
parentdc9d27425a4134e9a7a79c1a9b921e04c02d32dc (diff)
memory corruption fix (for 64-bit targets only)
git-svn-id: http://svn.miranda-ng.org/main/trunk@6140 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Variables/src/parse_miranda.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/plugins/Variables/src/parse_miranda.cpp b/plugins/Variables/src/parse_miranda.cpp
index 2e687a1fbf..de196803bc 100644
--- a/plugins/Variables/src/parse_miranda.cpp
+++ b/plugins/Variables/src/parse_miranda.cpp
@@ -473,33 +473,28 @@ static TCHAR *parseSpecialContact(ARGUMENTSINFO *ai)
return NULL;
ai->flags |= AIF_DONTPARSE;
- TCHAR *szUniqueID = NULL;
+ ptrT szUniqueID;
char *szProto = GetContactProto(ai->fi->hContact);
if (szProto != NULL)
szUniqueID = getContactInfoT(CNF_UNIQUEID, ai->fi->hContact);
if (szUniqueID == NULL) {
szProto = PROTOID_HANDLE;
- szUniqueID = (TCHAR*)mir_alloc(32);
- mir_sntprintf(szUniqueID, 32, _T("%p"), ai->fi->hContact);
- if (szProto == NULL || szUniqueID == NULL)
+ szUniqueID = (TCHAR*)mir_alloc(40);
+ if (szUniqueID == NULL)
return NULL;
+ mir_sntprintf(szUniqueID, 20, _T("%p"), ai->fi->hContact);
}
+ if (szUniqueID == NULL)
+ return NULL;
+
size_t size = strlen(szProto) + _tcslen(szUniqueID) + 4;
TCHAR *res = (TCHAR*)mir_alloc(size * sizeof(TCHAR));
- if (res == NULL) {
- mir_free(szUniqueID);
+ if (res == NULL)
return NULL;
- }
-
- TCHAR *tszProto = mir_a2t(szProto);
- if (tszProto != NULL && szUniqueID != NULL) {
- mir_sntprintf(res, size, _T("<%s:%s>"), tszProto, szUniqueID);
- mir_free(szUniqueID);
- mir_free(tszProto);
- }
+ mir_sntprintf(res, size, _T("<%S:%s>"), szProto, szUniqueID);
return res;
}