From 9f110a3b8162bd4066ca423c36bf2173420bfb3d Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Sun, 9 Nov 2003 19:33:39 +0000 Subject: [PATCH] CLI memory leak patch git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1712 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- asterisk.c | 5 +++++ cli.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/asterisk.c b/asterisk.c index 8e64773f6a..29c1645eb4 100755 --- a/asterisk.c +++ b/asterisk.c @@ -949,6 +949,7 @@ static char *cli_complete(EditLine *el, int ch) if (matches) { int i; + int x; int matches_num, maxlen, match_len; if (matches[0][0] != '\0') { @@ -978,6 +979,10 @@ static char *cli_complete(EditLine *el, int ch) retval = CC_REFRESH; } } + for (x=0; matches[x]; x++) { + free(matches[x]); + matches[x] = NULL; + } free(matches); } diff --git a/cli.c b/cli.c index ae6876fad1..544ead830b 100755 --- a/cli.c +++ b/cli.c @@ -864,12 +864,14 @@ int ast_cli_generatornummatches(char *text, char *word) while ( (buf = ast_cli_generator(text, word, i)) ) { if (++i > 1 && strcmp(buf,oldbuf) == 0) { + free(buf); continue; } oldbuf = buf; matches++; } - + free(oldbuf); + free(buf); return matches; }