[Asterisk-cvs] asterisk cli.c,1.53.2.9,1.53.2.10

russell russell
Sat Sep 24 17:22:36 CDT 2005


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv27947

Modified Files:
      Tag: v1-0
	cli.c 
Log Message:
Fix CLI memory leak (issue #5035)


Index: cli.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cli.c,v
retrieving revision 1.53.2.9
retrieving revision 1.53.2.10
diff -u -d -r1.53.2.9 -r1.53.2.10
--- cli.c	26 Aug 2005 15:54:25 -0000	1.53.2.9
+++ cli.c	24 Sep 2005 21:19:42 -0000	1.53.2.10
@@ -1004,14 +1004,15 @@
 	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;
 }
 




More information about the svn-commits mailing list