aboutsummaryrefslogtreecommitdiffstats
path: root/pbx
diff options
context:
space:
mode:
authormurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-05 18:23:53 +0000
committermurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-05 18:23:53 +0000
commit2acb6eaa29b9e72c3c25ec31c243d356b540e001 (patch)
tree8c058a4d055b0b281501eb684c35cb6baa89e8e8 /pbx
parent61e90275b323e33805427ce4adbe43db1d1c2d3b (diff)
Merged revisions 67420 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r67420 | murf | 2007-06-05 12:17:28 -0600 (Tue, 05 Jun 2007) | 1 line Added code to automatically add a default case to switches that don't have one. In some cases, rather than fall thru, it results in a goto with -1 result, which terminates the extension; a sort of dialplan seqfault, sort of. This was required to fix bug reported in 9881 ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@67423 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx')
-rw-r--r--pbx/pbx_ael.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/pbx/pbx_ael.c b/pbx/pbx_ael.c
index f62e95d93..5d3518c03 100644
--- a/pbx/pbx_ael.c
+++ b/pbx/pbx_ael.c
@@ -2325,6 +2325,33 @@ void check_switch_expr(pval *item, struct argapp *apps)
warns++;
}
}
+#else
+ pval *t,*tl=0,*p2;
+ int def= 0;
+
+ /* first of all, does this switch have a default case ? */
+ for (t=item->u2.statements; t; t=t->next) {
+ if (t->type == PV_DEFAULT) {
+ def =1;
+ break;
+ }
+ tl = t;
+ }
+ if (def) /* nothing to check. All cases accounted for! */
+ return;
+ /* if no default, warn and insert a default case at the end */
+ p2 = tl->next = calloc(1, sizeof(struct pval));
+
+ p2->type = PV_DEFAULT;
+ p2->startline = tl->startline;
+ p2->endline = tl->endline;
+ p2->startcol = tl->startcol;
+ p2->endcol = tl->endcol;
+ p2->filename = strdup(tl->filename);
+ ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: A default case was automatically added to the switch.\n",
+ p2->filename, p2->startline, p2->endline);
+ warns++;
+
#endif
}