[asterisk-bugs] [Asterisk 0015690]: [patch] ARG Variables are not overwritten when using empty values on macros

Asterisk Bug Tracker noreply at bugs.digium.com
Tue Dec 29 13:32:02 CST 2009


A NOTE has been added to this issue. 
====================================================================== 
https://issues.asterisk.org/view.php?id=15690 
====================================================================== 
Reported By:                diLLec
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   15690
Category:                   PBX/pbx_ael
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     acknowledged
Asterisk Version:           1.6.1.2 
JIRA:                        
Regression:                 No 
Reviewboard Link:            
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
====================================================================== 
Date Submitted:             2009-08-10 16:12 CDT
Last Modified:              2009-12-29 13:32 CST
====================================================================== 
Summary:                    [patch] ARG Variables are not overwritten when using
empty values on macros
Description: 
If you pass emtpy values inside of a macro to another macro, the ARG
arguments are not overwritten:

&MacroOne("one","two","three","four");

macro MacroOne (var1, var2, var3, var4) {
   var3=""; // also tried var=${} here - makes no difference
   &MacroTwo(${var1},${var2},${var4},${var3});
};

macro MacroTwo (var1, var2, var3, var4) {
   Verbose("Arg1 ${ARG1} Arg2 ${ARG2} Arg3 ${ARG3} Arg4 ${ARG4}");
};

As you can see in the output below, four is also assigned to var4 in
MacroTwo although it is passed as an empty value.

====================================================================== 

---------------------------------------------------------------------- 
 (0115826) coreyfarrell (reporter) - 2009-12-29 13:32
 https://issues.asterisk.org/view.php?id=15690#c115826 
---------------------------------------------------------------------- 
I've experience this issue as well, I've worked around in AEL scripts by
clearing ARG# variables.  AEL uses ARG# variables for temporary storage of
macro/gosub parameters, but never clears the variables.  AEL generates the
following contexts for MacroOne:

[ Context 'MacroOne' created by 'pbx_ael' ]
  's' =>            1. MSet(LOCAL(var1)=${ARG1})                 
[pbx_ael]
                    2. MSet(LOCAL(var2)=${ARG2})                 
[pbx_ael]
                    3. MSet(LOCAL(var3)=${ARG3})                 
[pbx_ael]
                    4. MSet(LOCAL(var4)=${ARG4})                 
[pbx_ael]
                    5. MSet(var3=$[""])                          
[pbx_ael]
                    6.
Gosub(MacroTwo,s,1(${var1},${var2},${var4},${var3})) [pbx_ael]
                    7. Return()                                  
[pbx_ael]

The problem is that ARG4 is never cleared. 
Gosub(MacroTwo,s,1(${var1},${var2},${var4},${var3})) seems to skip
assignment of ARG4 since ${var3} is blank.  My patch causes the following
context to be generated by the same AEL code:

[ Context 'MacroOne' created by 'pbx_ael' ]
  's' =>            1. MSet(LOCAL(var1)=${ARG1},ARG1=)           
[pbx_ael]
                    2. MSet(LOCAL(var2)=${ARG2},ARG2=)           
[pbx_ael]
                    3. MSet(LOCAL(var3)=${ARG3},ARG3=)           
[pbx_ael]
                    4. MSet(LOCAL(var4)=${ARG4},ARG4=)           
[pbx_ael]
                    5. MSet(var3=$[""])                          
[pbx_ael]
                    6.
Gosub(MacroTwo,s,1(${var1},${var2},${var4},${var3})) [pbx_ael]
                    7. Return()                                  
[pbx_ael]

I'm not sure if this should corrected in the Gosub code (ensure that blank
parameters are processed).  I choose to clear ARG# variables at the start
of each procedure.  The patch attached for 1.6.2.0-rc8 is good for 1.6.2.0
release.

Without the patch this issue can be worked around by manually clearing
ARG# variables at the start of procedures:

macro MacroOne (var1, var2, var3, var4) {
   ARG1="";
   ARG2="";
   ARG3="";
   ARG4=""; // this set's the default value of ARG4 to blank instead of
retaining the value of ${var4}
   var3="";
   &MacroTwo(${var1},${var2},${var4},${var3});
   // can also use: &MacroTwo(${var1},${var2},${var4},);
}; 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-12-29 13:32 coreyfarrell   Note Added: 0115826                          
======================================================================




More information about the asterisk-bugs mailing list