summaryrefslogtreecommitdiff
path: root/pbx
diff options
context:
space:
mode:
Diffstat (limited to 'pbx')
-rw-r--r--pbx/pbx_dundi.c20
-rw-r--r--pbx/pbx_loopback.c15
2 files changed, 21 insertions, 14 deletions
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 3c9704758..1d9ea840c 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -607,14 +607,18 @@ static int dundi_lookup_local(struct dundi_result *dr, struct dundi_mapping *map
ast_eid_to_str(dr[anscnt].eid_str, sizeof(dr[anscnt].eid_str), &dr[anscnt].eid);
if (ast_test_flag(&flags, DUNDI_FLAG_EXISTS)) {
AST_LIST_HEAD_INIT_NOLOCK(&headp);
- newvariable = ast_var_assign("NUMBER", called_number);
- AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
- newvariable = ast_var_assign("EID", dr[anscnt].eid_str);
- AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
- newvariable = ast_var_assign("SECRET", cursecret);
- AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
- newvariable = ast_var_assign("IPADDR", ipaddr);
- AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+ if ((newvariable = ast_var_assign("NUMBER", called_number))) {
+ AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+ }
+ if ((newvariable = ast_var_assign("EID", dr[anscnt].eid_str))) {
+ AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+ }
+ if ((newvariable = ast_var_assign("SECRET", cursecret))) {
+ AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+ }
+ if ((newvariable = ast_var_assign("IPADDR", ipaddr))) {
+ AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+ }
pbx_substitute_variables_varshead(&headp, map->dest, dr[anscnt].dest, sizeof(dr[anscnt].dest));
dr[anscnt].weight = get_mapping_weight(map, &headp);
while ((newvariable = AST_LIST_REMOVE_HEAD(&headp, entries)))
diff --git a/pbx/pbx_loopback.c b/pbx/pbx_loopback.c
index 5f3561343..dc9e7c7ac 100644
--- a/pbx/pbx_loopback.c
+++ b/pbx/pbx_loopback.c
@@ -91,12 +91,15 @@ static char *loopback_subst(char *buf, int buflen, const char *exten, const char
snprintf(tmp, sizeof(tmp), "%d", priority);
AST_LIST_HEAD_INIT_NOLOCK(&headp);
- newvariable = ast_var_assign("EXTEN", exten);
- AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
- newvariable = ast_var_assign("CONTEXT", context);
- AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
- newvariable = ast_var_assign("PRIORITY", tmp);
- AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+ if ((newvariable = ast_var_assign("EXTEN", exten))) {
+ AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+ }
+ if ((newvariable = ast_var_assign("CONTEXT", context))) {
+ AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+ }
+ if ((newvariable = ast_var_assign("PRIORITY", tmp))) {
+ AST_LIST_INSERT_HEAD(&headp, newvariable, entries);
+ }
/* Substitute variables */
pbx_substitute_variables_varshead(&headp, data, buf, buflen);
/* free the list */