diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-09-24 15:25:52 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-09-24 15:25:52 +0000 |
commit | 920ef427908a28dc83edc6cff768663a870b45ae (patch) | |
tree | af62e73f07f799c51c7cb1de2e51c865f68f58ac /cli.c | |
parent | d4c563761087b34ff2f248c3d6de0a0dea30d1b1 (diff) |
Fix CLI memory leak (bug #5035)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6635 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cli.c')
-rwxr-xr-x | cli.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -1203,14 +1203,15 @@ int ast_cli_generatornummatches(char *text, char *word) int matches = 0, i = 0; char *buf = NULL, *oldbuf = NULL; - while ( (buf = ast_cli_generator(text, word, i)) ) { - if (++i > 1 && strcmp(buf,oldbuf) == 0) { - continue; - } + while ( (buf = ast_cli_generator(text, word, i++)) ) { + if (!oldbuf || strcmp(buf,oldbuf)) + matches++; + if (oldbuf) + free(oldbuf); oldbuf = buf; - matches++; } - + if (oldbuf) + free(oldbuf); return matches; } |