diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-04-08 13:45:36 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-04-08 13:45:36 +0000 |
commit | 2ac8552c3a7ca0e4af0ce80e722a515e9031d641 (patch) | |
tree | c486ebb15ee9d101ffc846c11bb6405b7c829e86 /cli.c | |
parent | 34567e719d310a0e3948686703359218e08885f9 (diff) |
Fix some leaks in CLI (thanks James)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@777 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cli.c')
-rwxr-xr-x | cli.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -278,7 +278,10 @@ static int handle_commandmatchesarray(int fd, int argc, char *argv[]) printf("command matchesarray for '%s' %s got '%s'\n", argv[2], argv[3], matches[x]); #endif len += sprintf( buf + len, "%s ", matches[x]); + free(matches[x]); + matches[x] = NULL; } + free(matches); } #if 0 printf("array for '%s' %s got '%s'\n", argv[2], argv[3], buf); @@ -765,12 +768,16 @@ normal: int ast_cli_generatornummatches(char *text, char *word) { int matches = 0, i = 0; - char *buf, *oldbuf; + char *buf, *oldbuf = NULL; while ( (buf = ast_cli_generator(text, word, i)) ) { - if (++i > 1 && strcmp(buf,oldbuf) == 0) + if (++i > 1 && strcmp(buf,oldbuf) == 0) { + free(buf); continue; + } + if (oldbuf) + free(oldbuf); oldbuf = buf; matches++; } @@ -866,6 +873,7 @@ static char *__ast_cli_generator(char *text, char *word, int state, int lock) if (res) { if (lock) ast_pthread_mutex_unlock(&clilock); + free(dup); return res ? strdup(res) : NULL; } } |