[asterisk-commits] murf: branch 1.4 r67420 - /branches/1.4/pbx/pbx_ael.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Jun 5 11:17:28 MST 2007


Author: murf
Date: Tue Jun  5 13:17:28 2007
New Revision: 67420

URL: http://svn.digium.com/view/asterisk?view=rev&rev=67420
Log:
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

Modified:
    branches/1.4/pbx/pbx_ael.c

Modified: branches/1.4/pbx/pbx_ael.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/pbx/pbx_ael.c?view=diff&rev=67420&r1=67419&r2=67420
==============================================================================
--- branches/1.4/pbx/pbx_ael.c (original)
+++ branches/1.4/pbx/pbx_ael.c Tue Jun  5 13:17:28 2007
@@ -2208,6 +2208,33 @@
 			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
 }
 



More information about the asterisk-commits mailing list