[Home]

Summary:ASTERISK-13071: switch statement: Empty patterns don't fallback to Default label
Reporter:Matthias Urlichs (smurfix)Labels:
Date Opened:2008-11-14 07:48:58.000-0600Date Closed:2008-11-20 13:44:14.000-0600
Priority:MajorRegression?No
Status:Closed/CompleteComponents:PBX/pbx_ael
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20081118_bug13901.diff
Description:The following code:

switch(${empty}) {

... some patterns ...

default: break;

}

results in an "unknown label" error, the call is aborted.

This bug caused us to lose two days' worth of calls which happened not to send any caller ID ...

****** ADDITIONAL INFORMATION ******

   -- Executing [s@cidalcatel:3] Goto("DAHDI/7-1", "sw-113-,10") in new stack
   -- Goto (cidalcatel,sw-113-,10)
   -- Executing [sw-113-@cidalcatel:10] Goto("DAHDI/7-1", "sw-113-.|10") in new stack
[Nov 14 14:28:13] NOTICE[23293]: pbx.c:3219 pbx_extension_helper: No such label 'sw-113-.|10' in extension 'sw-113-' in context 'cidalcatel'
[Nov 14 14:28:13] WARNING[23293]: pbx.c:8842 pbx_parseable_goto: Priority 'sw-113-.|10' must be a number > 0, or valid label
Comments:By: Steve Murphy (murf) 2008-11-14 13:00:21.000-0600

Sorry about that! As an immediate sort of work-around, you could
prepend or append something, say another digit, to the variable, so it
is guaranteed never to be null...

Like:

  switch(0${maybe_empty_var}) {
     case 0123:
     case 0954:
        ..
     case 0:  /* the equiv of default */
     default:
       /* whatever */
  }



By: Sean Bright (seanbright) 2008-11-18 19:34:20.000-0600

smurfix,

Could you try the attached patch and see if it resolves this issue?  It works here in my local testing.

Thanks.

By: Steve Murphy (murf) 2008-11-19 09:05:11.000-0600

seanbright-- good work! I searched for all occurrences of '|' in pval,
and that appears to be the only one. How I missed it, I cannot say.
Good detective work.

By: Sean Bright (seanbright) 2008-11-20 13:44:14.000-0600

Fix one case where the application argument was not converted from a pipe to
a comma.  This was causing problems with switch statements with empty expressions.

(closes issue ASTERISK-13071)
Reported by: smurfix
Patches:
     20081118_bug13901.diff uploaded by seanbright (license 71)
Tested by: seanbright
Reviewed by: murf

Modified:
   trunk/res/ael/pval.c