diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2015-01-10 18:44:06 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2015-01-10 18:44:06 +0000 |
commit | 2cd05c2649104e8690defdcf0122d8c3e827c1d2 (patch) | |
tree | e778d1ebc66f1942eab066d8de5b0a77e612ef5f /plugins/Variables/src/parse_alias.cpp | |
parent | e5972722ef981be64fe46ca8c07c2c403458e255 (diff) |
Variables:
- Fixed various memory leaks
git-svn-id: http://svn.miranda-ng.org/main/trunk@11821 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Variables/src/parse_alias.cpp')
-rw-r--r-- | plugins/Variables/src/parse_alias.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/plugins/Variables/src/parse_alias.cpp b/plugins/Variables/src/parse_alias.cpp index d9b31ace06..13c771f128 100644 --- a/plugins/Variables/src/parse_alias.cpp +++ b/plugins/Variables/src/parse_alias.cpp @@ -116,14 +116,15 @@ static int addToAliasRegister(TCHAR *szAlias, unsigned int argc, TCHAR** argv, T }
return 0;
}
+ TCHAR **pargv = (TCHAR**)mir_alloc(argc * sizeof(TCHAR*));
+ if (pargv == NULL)
+ return -1;
ALIASREGISTER *p = new ALIASREGISTER;
p->szAlias = mir_tstrdup(szAlias);
p->szTranslation = mir_tstrdup(szTranslation);
p->argc = argc;
- p->argv = (TCHAR**)mir_alloc(argc * sizeof(TCHAR*));
- if (p->argv == NULL)
- return -1;
+ p->argv = pargv;
for (unsigned j = 0; j < p->argc; j++) {
if (argv[j] != NULL)
@@ -137,12 +138,10 @@ static int addToAliasRegister(TCHAR *szAlias, unsigned int argc, TCHAR** argv, T static TCHAR *parseAddAlias(ARGUMENTSINFO *ai)
{
- int res;
- char *szHelp, *szArgsA;
-
if (ai->argc != 3)
return NULL;
+ char *szHelp, *szArgsA;
TCHAR *cur = ai->targv[1];
while (isValidTokenChar(*cur))
cur++;
@@ -165,6 +164,7 @@ static TCHAR *parseAddAlias(ARGUMENTSINFO *ai) if (i != argc - 1)
_tcscat(szArgs, _T(","));
}
+ int res;
if (szArgs != NULL && argc > 0) {
szArgsA = mir_t2a(szArgs);
@@ -183,6 +183,7 @@ static TCHAR *parseAddAlias(ARGUMENTSINFO *ai) }
mir_free(szArgs);
mir_free(szHelp);
+ mir_free(argv);
return (res == 0) ? mir_tstrdup(_T("")) : NULL;
}
|