mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-11 20:38:45 +00:00
tab completion on show dialplan from -r asterisk with large extensions.conf will segfault (bug #2634)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@4008 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
18
cli.c
18
cli.c
@@ -437,11 +437,11 @@ static char *__ast_cli_generator(char *text, char *word, int state, int lock);
|
||||
|
||||
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 @@ static int handle_commandmatchesarray(int fd, int argc, char *argv[])
|
||||
#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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user