]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
(closes issue #11903)
authorSteve Murphy <murf@digium.com>
Tue, 18 Mar 2008 06:37:15 +0000 (06:37 +0000)
committerSteve Murphy <murf@digium.com>
Tue, 18 Mar 2008 06:37:15 +0000 (06:37 +0000)
Reported by: atis

Many thanks to atis for spotting this problem and reporting it.
The fix was to straighten out how items are placed on and removed
from the file stack. Regressions as well as the provided test case
helped to straighten out all code paths. valgrind was used to make
sure all memory allocated was freed.

Sorry for not solving this earlier. I got distracted.

Added the ntest23 regression test, which is mainly a copy of ntest22,
but with a few juicy errors thrown in, to replicate the kind of
error that atis spotted.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@109309 65c4cc65-6c06-0410-ace0-fbb531ad65f3

15 files changed:
pbx/ael/ael-test/ael-ntest23/extensions.ael [new file with mode: 0644]
pbx/ael/ael-test/ael-ntest23/qq.ael [new file with mode: 0644]
pbx/ael/ael-test/ael-ntest23/t1/a.ael [new file with mode: 0644]
pbx/ael/ael-test/ael-ntest23/t1/b.ael [new file with mode: 0644]
pbx/ael/ael-test/ael-ntest23/t1/c.ael [new file with mode: 0644]
pbx/ael/ael-test/ael-ntest23/t2/d.ael [new file with mode: 0644]
pbx/ael/ael-test/ael-ntest23/t2/e.ael [new file with mode: 0644]
pbx/ael/ael-test/ael-ntest23/t2/f.ael [new file with mode: 0644]
pbx/ael/ael-test/ael-ntest23/t3/g.ael [new file with mode: 0644]
pbx/ael/ael-test/ael-ntest23/t3/h.ael [new file with mode: 0644]
pbx/ael/ael-test/ael-ntest23/t3/i.ael [new file with mode: 0644]
pbx/ael/ael-test/ael-ntest23/t3/j.ael [new file with mode: 0644]
pbx/ael/ael-test/ref.ael-ntest23 [new file with mode: 0644]
pbx/ael/ael.flex
pbx/ael/ael_lex.c

diff --git a/pbx/ael/ael-test/ael-ntest23/extensions.ael b/pbx/ael/ael-test/ael-ntest23/extensions.ael
new file mode 100644 (file)
index 0000000..7128258
--- /dev/null
@@ -0,0 +1,7 @@
+#include "t1/*.ael"
+
+context z ()
+{
+       123 => NoOp(hi there, z);
+       124 => NoOp(hi there, z);
+}
diff --git a/pbx/ael/ael-test/ael-ntest23/qq.ael b/pbx/ael/ael-test/ael-ntest23/qq.ael
new file mode 100644 (file)
index 0000000..c446f53
--- /dev/null
@@ -0,0 +1,6 @@
+
+
+context qq
+{
+       567 => NoOp(hi there, qq);
+}
diff --git a/pbx/ael/ael-test/ael-ntest23/t1/a.ael b/pbx/ael/ael-test/ael-ntest23/t1/a.ael
new file mode 100644 (file)
index 0000000..62e3fc5
--- /dev/null
@@ -0,0 +1,4 @@
+context a
+{
+       134 => NoOp(hi there, a);
+}
diff --git a/pbx/ael/ael-test/ael-ntest23/t1/b.ael b/pbx/ael/ael-test/ael-ntest23/t1/b.ael
new file mode 100644 (file)
index 0000000..29d8d1f
--- /dev/null
@@ -0,0 +1,6 @@
+
+
+context b
+{
+       456 => NoOp(hithere, b);
+}
diff --git a/pbx/ael/ael-test/ael-ntest23/t1/c.ael b/pbx/ael/ael-test/ael-ntest23/t1/c.ael
new file mode 100644 (file)
index 0000000..d18eb76
--- /dev/null
@@ -0,0 +1,13 @@
+
+
+context c()
+{
+       567 => NoOp(hi there, c);
+}
+
+#include "t2/*.ael"
+
+context w()
+{
+       890 => NoOp(hi there, w);
+}
diff --git a/pbx/ael/ael-test/ael-ntest23/t2/d.ael b/pbx/ael/ael-test/ael-ntest23/t2/d.ael
new file mode 100644 (file)
index 0000000..6362278
--- /dev/null
@@ -0,0 +1,4 @@
+context d
+{
+       134 => NoOp(hi there, d);
+}
diff --git a/pbx/ael/ael-test/ael-ntest23/t2/e.ael b/pbx/ael/ael-test/ael-ntest23/t2/e.ael
new file mode 100644 (file)
index 0000000..9465c8b
--- /dev/null
@@ -0,0 +1,6 @@
+
+
+context e
+{
+       456 => NoOp(hithere, e);
+}
diff --git a/pbx/ael/ael-test/ael-ntest23/t2/f.ael b/pbx/ael/ael-test/ael-ntest23/t2/f.ael
new file mode 100644 (file)
index 0000000..ba15a63
--- /dev/null
@@ -0,0 +1,9 @@
+#include "qq.ael"
+
+context f
+{
+       567 => NoOp(hi there, f);
+}
+
+#include "t3/*.ael"
+
diff --git a/pbx/ael/ael-test/ael-ntest23/t3/g.ael b/pbx/ael/ael-test/ael-ntest23/t3/g.ael
new file mode 100644 (file)
index 0000000..0f1ecc8
--- /dev/null
@@ -0,0 +1,4 @@
+context g
+{
+       134 => NoOp(hi there, g);
+}
diff --git a/pbx/ael/ael-test/ael-ntest23/t3/h.ael b/pbx/ael/ael-test/ael-ntest23/t3/h.ael
new file mode 100644 (file)
index 0000000..f9e3ca8
--- /dev/null
@@ -0,0 +1,6 @@
+
+
+context h
+{
+       456 => NoOp(hithere, h);
+}
diff --git a/pbx/ael/ael-test/ael-ntest23/t3/i.ael b/pbx/ael/ael-test/ael-ntest23/t3/i.ael
new file mode 100644 (file)
index 0000000..5639a1e
--- /dev/null
@@ -0,0 +1,4 @@
+context i
+{
+       134 => NoOp(hi there, i);
+}
diff --git a/pbx/ael/ael-test/ael-ntest23/t3/j.ael b/pbx/ael/ael-test/ael-ntest23/t3/j.ael
new file mode 100644 (file)
index 0000000..8dfc6c0
--- /dev/null
@@ -0,0 +1,6 @@
+
+
+context j
+{
+       567 => NoOp(hi there, j);
+}
diff --git a/pbx/ael/ael-test/ref.ael-ntest23 b/pbx/ael/ael-test/ref.ael-ntest23
new file mode 100644 (file)
index 0000000..5f8f2a8
--- /dev/null
@@ -0,0 +1,25 @@
+
+(If you find progress and other non-error messages irritating, you can use -q to suppress them)
+
+(You can use the -n option if you aren't interested in seeing all the instructions generated by the compiler)
+
+
+(You can use the -w option to dump extensions.conf format to extensions.conf.aeldump)
+LOG: lev:2 file:pbx_ael.c  line:4094 func: pbx_load_module  Starting AEL load process.
+LOG: lev:2 file:pbx_ael.c  line:4101 func: pbx_load_module  AEL load process: calculated config file name './extensions.ael'.
+LOG: lev:2 file:ael.flex  line:663 func: setup_filestack    --Read in included file ./t1/a.ael, 41 chars
+LOG: lev:2 file:ael.flex  line:663 func: setup_filestack    --Read in included file ./t1/b.ael, 42 chars
+LOG: lev:2 file:ael.flex  line:663 func: setup_filestack    --Read in included file ./t1/c.ael, 110 chars
+LOG: lev:4 file:ael.y  line:756 func: ael_yyerror  ==== File: ./t1/c.ael, Line 3, Cols: 10-10: Error: syntax error, unexpected '(', expecting '{'
+LOG: lev:2 file:ael.flex  line:663 func: setup_filestack    --Read in included file ./t2/d.ael, 41 chars
+LOG: lev:2 file:ael.flex  line:663 func: setup_filestack    --Read in included file ./t2/e.ael, 42 chars
+LOG: lev:2 file:ael.flex  line:663 func: setup_filestack    --Read in included file ./t2/f.ael, 82 chars
+LOG: lev:2 file:ael.flex  line:663 func: setup_filestack    --Read in included file ./qq.ael, 45 chars
+LOG: lev:2 file:ael.flex  line:663 func: setup_filestack    --Read in included file ./t3/g.ael, 41 chars
+LOG: lev:2 file:ael.flex  line:663 func: setup_filestack    --Read in included file ./t3/h.ael, 42 chars
+LOG: lev:2 file:ael.flex  line:663 func: setup_filestack    --Read in included file ./t3/i.ael, 41 chars
+LOG: lev:2 file:ael.flex  line:663 func: setup_filestack    --Read in included file ./t3/j.ael, 43 chars
+LOG: lev:4 file:ael.y  line:756 func: ael_yyerror  ==== File: ./t1/c.ael, Line 10, Cols: 10-10: Error: syntax error, unexpected '(', expecting '{'
+LOG: lev:2 file:pbx_ael.c  line:4109 func: pbx_load_module  AEL load process: parsed config file name './extensions.ael'.
+LOG: lev:4 file:pbx_ael.c  line:4122 func: pbx_load_module  Sorry, but 2 syntax errors and 0 semantic errors were detected. It doesn't make sense to compile.
+LOG: lev:4 file:ael2_parse  line:543 func: main  0 contexts, 0 extensions, 0 priorities
index 3c910cfef772cda2e335ee7eee5d900f717fe9c5..866e3617071e61a905ffb70dac00b6d2524ab6ae 100644 (file)
@@ -438,8 +438,6 @@ includes    { STORE_POS; return KW_INCLUDES;}
 <<EOF>>                {
                char fnamebuf[2048];
                if (include_stack_index > 0 && include_stack[include_stack_index-1].globbuf_pos < include_stack[include_stack_index-1].globbuf.gl_pathc-1) {
-                       free(my_file);
-                       my_file = 0;
                        yy_delete_buffer( YY_CURRENT_BUFFER, yyscanner );
                        include_stack[include_stack_index-1].globbuf_pos++;
                        setup_filestack(fnamebuf, sizeof(fnamebuf), &include_stack[include_stack_index-1].globbuf, include_stack[include_stack_index-1].globbuf_pos, yyscanner, 0);
@@ -450,13 +448,13 @@ includes  { STORE_POS; return KW_INCLUDES;}
                                free(include_stack[include_stack_index].fname);
                                include_stack[include_stack_index].fname = 0;
                        }
+                       if (my_file) {
+                               free(my_file);
+                               my_file = 0;
+                       }
                        if ( --include_stack_index < 0 ) {
                                yyterminate();
                        } else {
-                               if (my_file) {
-                                       free(my_file);
-                                       my_file = 0;
-                               }
                                globfree(&include_stack[include_stack_index].globbuf);
                                include_stack[include_stack_index].globbuf_pos = -1;
                                
@@ -663,12 +661,16 @@ static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf,
                        buffer[stats.st_size] = 0;
                        ast_log(LOG_NOTICE,"  --Read in included file %s, %d chars\n",fnamebuf2, (int)stats.st_size);
                        fclose(in1);
-                       if (my_file)
-                               free(my_file);
-                       my_file = strdup(fnamebuf2);
+                       if (include_stack[include_stack_index].fname) {
+                               free(include_stack[include_stack_index].fname);
+                               include_stack[include_stack_index].fname = 0;
+                       }
                        include_stack[include_stack_index].fname = strdup(my_file);
                        include_stack[include_stack_index].lineno = my_lineno;
                        include_stack[include_stack_index].colno = my_col+yyleng;
+                       if (my_file)
+                               free(my_file);
+                       my_file = strdup(fnamebuf2);
                        if (create)
                                include_stack[include_stack_index].globbuf = *globbuf;
 
index 09199ab4fedc3165a3c88ffab11bf70541d17149..708387829c65030ef23783ae9798f8d2f6cb264d 100644 (file)
@@ -1735,8 +1735,6 @@ case YY_STATE_EOF(comment):
 {
                char fnamebuf[2048];
                if (include_stack_index > 0 && include_stack[include_stack_index-1].globbuf_pos < include_stack[include_stack_index-1].globbuf.gl_pathc-1) {
-                       free(my_file);
-                       my_file = 0;
                        ael_yy_delete_buffer(YY_CURRENT_BUFFER,yyscanner );
                        include_stack[include_stack_index-1].globbuf_pos++;
                        setup_filestack(fnamebuf, sizeof(fnamebuf), &include_stack[include_stack_index-1].globbuf, include_stack[include_stack_index-1].globbuf_pos, yyscanner, 0);
@@ -1747,13 +1745,13 @@ case YY_STATE_EOF(comment):
                                free(include_stack[include_stack_index].fname);
                                include_stack[include_stack_index].fname = 0;
                        }
+                       if (my_file) {
+                               free(my_file);
+                               my_file = 0;
+                       }
                        if ( --include_stack_index < 0 ) {
                                yyterminate();
                        } else {
-                               if (my_file) {
-                                       free(my_file);
-                                       my_file = 0;
-                               }
                                globfree(&include_stack[include_stack_index].globbuf);
                                include_stack[include_stack_index].globbuf_pos = -1;
                                
@@ -1768,10 +1766,10 @@ case YY_STATE_EOF(comment):
        YY_BREAK
 case 62:
 YY_RULE_SETUP
-#line 472 "ael.flex"
+#line 470 "ael.flex"
 ECHO;
        YY_BREAK
-#line 1774 "ael_lex.c"
+#line 1772 "ael_lex.c"
 
        case YY_END_OF_BUFFER:
                {
@@ -2896,7 +2894,7 @@ void *ael_yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 472 "ael.flex"
+#line 470 "ael.flex"
 
 
 
@@ -3092,12 +3090,16 @@ static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf,
                        buffer[stats.st_size] = 0;
                        ast_log(LOG_NOTICE,"  --Read in included file %s, %d chars\n",fnamebuf2, (int)stats.st_size);
                        fclose(in1);
-                       if (my_file)
-                               free(my_file);
-                       my_file = strdup(fnamebuf2);
+                       if (include_stack[include_stack_index].fname) {
+                               free(include_stack[include_stack_index].fname);
+                               include_stack[include_stack_index].fname = 0;
+                       }
                        include_stack[include_stack_index].fname = strdup(my_file);
                        include_stack[include_stack_index].lineno = my_lineno;
                        include_stack[include_stack_index].colno = my_col+yyleng;
+                       if (my_file)
+                               free(my_file);
+                       my_file = strdup(fnamebuf2);
                        if (create)
                                include_stack[include_stack_index].globbuf = *globbuf;