diff options
Diffstat (limited to 'channels/iax2-provision.c')
-rw-r--r-- | channels/iax2-provision.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/channels/iax2-provision.c b/channels/iax2-provision.c index c1b6f4b3d..420e79213 100644 --- a/channels/iax2-provision.c +++ b/channels/iax2-provision.c @@ -156,21 +156,20 @@ char *iax_prov_complete_template(char *line, char *word, int pos, int state) { struct iax_template *c; int which=0; - char *ret; + char *ret = NULL; + int wordlen = strlen(word); + ast_mutex_lock(&provlock); - c = templates; - while(c) { - if (!strncasecmp(word, c->name, strlen(word))) { - if (++which > state) + for (c = templates; c; c = c->next) { + if (!strncasecmp(word, c->name, wordlen)) { + if (++which > state) { + ret = strdup(c->name); break; + } } - c = c->next; } - if (c) { - ret = strdup(c->name); - } else - ret = NULL; ast_mutex_unlock(&provlock); + return ret; } |