aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authormurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2008-03-18 15:14:22 +0000
committermurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2008-03-18 15:14:22 +0000
commit377fddb7a04df80601ca8cf2806786b6ed38196b (patch)
tree180ce7f6b796d1e818e24ebb96fe23f29a6b2408 /res
parent990061d97c5d26d27c3404d8d8b6aefb07b7e660 (diff)
Merged revisions 109357 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r109357 | murf | 2008-03-18 08:09:50 -0600 (Tue, 18 Mar 2008) | 25 lines Merged revisions 109309 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r109309 | murf | 2008-03-18 00:37:15 -0600 (Tue, 18 Mar 2008) | 17 lines (closes issue #11903) 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: http://svn.digium.com/svn/asterisk/branches/1.6.0@109397 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r--res/ael/ael.flex20
-rw-r--r--res/ael/ael_lex.c21
2 files changed, 23 insertions, 18 deletions
diff --git a/res/ael/ael.flex b/res/ael/ael.flex
index cf2d36a2c..35ca126aa 100644
--- a/res/ael/ael.flex
+++ b/res/ael/ael.flex
@@ -445,8 +445,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);
@@ -457,13 +455,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;
@@ -670,12 +668,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;
diff --git a/res/ael/ael_lex.c b/res/ael/ael_lex.c
index 26206af5d..1f96e3377 100644
--- a/res/ael/ael_lex.c
+++ b/res/ael/ael_lex.c
@@ -793,6 +793,7 @@ static yyconst flex_int16_t yy_chk[1035] =
* bison-locations is probably not needed.
*/
#line 63 "ael.flex"
+#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <sys/types.h>
@@ -1745,8 +1746,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);
@@ -1757,13 +1756,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;
@@ -3102,12 +3101,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;