[Asterisk-cvs] asterisk cli.c,1.53.2.1,1.53.2.2
russell at lists.digium.com
russell at lists.digium.com
Thu Oct 14 18:50:54 CDT 2004
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv15250
Modified Files:
Tag: v1-0
cli.c
Log Message:
tab completion on show dialplan from -r asterisk with large extensions.conf will segfault (bug #2634)
Index: cli.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cli.c,v
retrieving revision 1.53.2.1
retrieving revision 1.53.2.2
diff -u -d -r1.53.2.1 -r1.53.2.2
--- cli.c 8 Oct 2004 23:29:50 -0000 1.53.2.1
+++ cli.c 14 Oct 2004 22:51:14 -0000 1.53.2.2
@@ -437,11 +437,11 @@
static int handle_commandmatchesarray(int fd, int argc, char *argv[])
{
- char *buf;
+ char *buf, *obuf;
int buflen = 2048;
int len = 0;
char **matches;
- int x;
+ int x, matchlen;
if (argc != 4)
return RESULT_SHOWUSAGE;
@@ -455,11 +455,17 @@
#if 0
printf("command matchesarray for '%s' %s got '%s'\n", argv[2], argv[3], matches[x]);
#endif
- if (len + strlen(matches[x]) >= buflen) {
- buflen += strlen(matches[x]) * 3;
- buf = realloc(buf, buflen);
+ matchlen = strlen(matches[x]) + 1;
+ if (len + matchlen >= buflen) {
+ buflen += matchlen * 3;
+ obuf = buf;
+ buf = realloc(obuf, buflen);
+ if (!buf)
+ /* Out of memory... Just free old buffer and be done */
+ free(obuf);
}
- len += sprintf( buf + len, "%s ", matches[x]);
+ if (buf)
+ len += sprintf( buf + len, "%s ", matches[x]);
free(matches[x]);
matches[x] = NULL;
}
More information about the svn-commits
mailing list