summaryrefslogtreecommitdiff
path: root/cli.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2005-09-24 15:25:52 +0000
committerMark Spencer <markster@digium.com>2005-09-24 15:25:52 +0000
commit7196493caa9bee74905eda09e88dc199cae4941c (patch)
treeaf62e73f07f799c51c7cb1de2e51c865f68f58ac /cli.c
parent2e5537a4a0b40c9e1f048f270087dded98e2945c (diff)
Fix CLI memory leak (bug #5035)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6635 65c4cc65-6c06-0410-ace0-fbb531ad65f3
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;
}