From 7c51a5c643c99f624147bd0fb56f5c29d65fd5dc Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 29 Nov 2014 19:34:27 +0000 Subject: finally catched wrong memory allocation in variables git-svn-id: http://svn.miranda-ng.org/main/trunk@11156 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Variables/src/parse_miranda.cpp | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'plugins/Variables/src') diff --git a/plugins/Variables/src/parse_miranda.cpp b/plugins/Variables/src/parse_miranda.cpp index 6516b5ea18..335df51fb3 100644 --- a/plugins/Variables/src/parse_miranda.cpp +++ b/plugins/Variables/src/parse_miranda.cpp @@ -416,7 +416,7 @@ static TCHAR* parseProtoInfo(ARGUMENTSINFO *ai) char *szRes = NULL; TCHAR *tszRes = NULL; - char *szProto = mir_t2a(ai->targv[1]); + ptrA szProto(mir_t2a(ai->targv[1])); if (!_tcscmp(ai->targv[2], _T(STR_PINAME))) tszRes = Hlp_GetProtocolName(szProto); @@ -424,42 +424,29 @@ static TCHAR* parseProtoInfo(ARGUMENTSINFO *ai) if (!ProtoServiceExists(szProto, PS_GETCAPS)) return NULL; - char *szText = (char *)CallProtoService(szProto, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDTEXT, 0); - if (szText != NULL) - szRes = _strdup(szText); + szRes = (char *)CallProtoService(szProto, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDTEXT, 0); } else if (!_tcscmp(ai->targv[2], _T(STR_PIUIDSETTING))) { if (!ProtoServiceExists(szProto, PS_GETCAPS)) return NULL; - char *szText = (char *)CallProtoService(szProto, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDSETTING, 0); - if (szText != NULL) - szRes = _strdup(szText); + szRes = (char *)CallProtoService(szProto, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDSETTING, 0); } - else if (!_tcscmp(ai->targv[2], _T(STR_PINICK))) - { + else if (!_tcscmp(ai->targv[2], _T(STR_PINICK))) { CONTACTINFO ci; - ci.cbSize = sizeof(CONTACTINFO); ci.dwFlag = CNF_DISPLAY | CNF_UNICODE; ci.hContact = NULL; ci.szProto = szProto; CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci); - - tszRes = mir_tstrdup(ci.pszVal); - - mir_free(ci.pszVal); + tszRes = ci.pszVal; } - mir_free(szProto); + if (szRes == NULL && tszRes == NULL) return NULL; - if (szRes != NULL && tszRes == NULL) { + if (szRes != NULL && tszRes == NULL) tszRes = mir_a2t(szRes); - mir_free(szRes); - } - else if (szRes != NULL && tszRes != NULL) - mir_free(szRes); return tszRes; } -- cgit v1.2.3