mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Fix CLI memory leak (bug #5035)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6635 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
13
cli.c
13
cli.c
@@ -1203,14 +1203,15 @@ int ast_cli_generatornummatches(char *text, char *word)
|
|||||||
int matches = 0, i = 0;
|
int matches = 0, i = 0;
|
||||||
char *buf = NULL, *oldbuf = NULL;
|
char *buf = NULL, *oldbuf = NULL;
|
||||||
|
|
||||||
while ( (buf = ast_cli_generator(text, word, i)) ) {
|
while ( (buf = ast_cli_generator(text, word, i++)) ) {
|
||||||
if (++i > 1 && strcmp(buf,oldbuf) == 0) {
|
if (!oldbuf || strcmp(buf,oldbuf))
|
||||||
continue;
|
matches++;
|
||||||
}
|
if (oldbuf)
|
||||||
|
free(oldbuf);
|
||||||
oldbuf = buf;
|
oldbuf = buf;
|
||||||
matches++;
|
|
||||||
}
|
}
|
||||||
|
if (oldbuf)
|
||||||
|
free(oldbuf);
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user