aboutsummaryrefslogtreecommitdiffstats
path: root/cli.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-09-24 15:25:52 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-09-24 15:25:52 +0000
commit920ef427908a28dc83edc6cff768663a870b45ae (patch)
treeaf62e73f07f799c51c7cb1de2e51c865f68f58ac /cli.c
parentd4c563761087b34ff2f248c3d6de0a0dea30d1b1 (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-xcli.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/cli.c b/cli.c
index e6e8d0b22..8e22353fa 100755
--- a/cli.c
+++ b/cli.c
@@ -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;
}