diff options
author | Tilghman Lesher <tilghman@meg.abyt.es> | 2008-01-09 00:51:59 +0000 |
---|---|---|
committer | Tilghman Lesher <tilghman@meg.abyt.es> | 2008-01-09 00:51:59 +0000 |
commit | 43a172de573fb0e0a8170e07f42b8c0c5f2de2b4 (patch) | |
tree | f97ce3c3f8d211a894ebf26c0fde036040258cb6 /main/cli.c | |
parent | c1eaacc3dfeb040eea723f7edc675df8f00a2a4b (diff) |
Merged revisions 97350 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r97350 | tilghman | 2008-01-08 18:44:14 -0600 (Tue, 08 Jan 2008) | 5 lines
Allow filename completion on zero-length modules, remove a memory leak, remove
a file descriptor leak, and make filename completion thread-safe.
Patched and tested by tilghman.
(Closes issue #11681)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@97364 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/cli.c')
-rw-r--r-- | main/cli.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/main/cli.c b/main/cli.c index 94ed6b565..c412d63c7 100644 --- a/main/cli.c +++ b/main/cli.c @@ -121,7 +121,7 @@ static AST_RWLIST_HEAD_STATIC(helpers, ast_cli_entry); static char *complete_fn(const char *word, int state) { - char *c; + char *c, *d; char filename[256]; if (word[0] == '/') @@ -129,13 +129,15 @@ static char *complete_fn(const char *word, int state) else snprintf(filename, sizeof(filename), "%s/%s", ast_config_AST_MODULE_DIR, word); - /* XXX the following function is not reentrant, so we better not use it */ - c = filename_completion_function(filename, state); + c = d = filename_completion_function(filename, state); if (c && word[0] != '/') c += (strlen(ast_config_AST_MODULE_DIR) + 1); + if (c) + c = ast_strdup(c); + free(d); - return c ? ast_strdup(c) : c; + return c; } static char *handle_load(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |