aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2010-05-02 11:40:46 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2010-05-02 11:40:46 +0200
commit34f92dcfba414327180e21932761d38c5e69d0c8 (patch)
tree0b42064e11d7b37d050aefa3bad6d36ab79c11b6
parent2724ae521e50c34755dac2abc190785b5c4edaa6 (diff)
downloadstrongswan-34f92dcfba414327180e21932761d38c5e69d0c8.tar.bz2
strongswan-34f92dcfba414327180e21932761d38c5e69d0c8.tar.xz
fixed flex parser memory leaks in ipsec starter
-rw-r--r--src/starter/parser.l4
-rw-r--r--src/starter/parser.y16
2 files changed, 10 insertions, 10 deletions
diff --git a/src/starter/parser.l b/src/starter/parser.l
index 5857c0815..c45847c5c 100644
--- a/src/starter/parser.l
+++ b/src/starter/parser.l
@@ -24,7 +24,8 @@
#define MAX_INCLUDE_DEPTH 20
extern void yyerror(const char *);
-extern int yylex (void);
+extern int yylex(void);
+extern int yylex_destroy(void);
static struct {
int stack_ptr;
@@ -68,6 +69,7 @@ void _parser_y_fini (void)
fclose(__parser_y_private.file[i]);
}
memset(&__parser_y_private, 0, sizeof(__parser_y_private));
+ yylex_destroy();
}
int _parser_y_include (const char *filename)
diff --git a/src/starter/parser.y b/src/starter/parser.y
index 4533228c2..b0b1f6f21 100644
--- a/src/starter/parser.y
+++ b/src/starter/parser.y
@@ -156,21 +156,20 @@ statement_kw:
%%
-void
-yyerror(const char *s)
+void yyerror(const char *s)
{
if (_save_errors_)
_parser_y_error(parser_errstring, ERRSTRING_LEN, s);
}
-config_parsed_t *
-parser_load_conf(const char *file)
+config_parsed_t *parser_load_conf(const char *file)
{
config_parsed_t *cfg = NULL;
int err = 0;
FILE *f;
- extern void _parser_y_init (const char *f);
+ extern void _parser_y_init(const char *f);
+ extern void _parser_y_fini(void);
extern FILE *yyin;
memset(parser_errstring, 0, ERRSTRING_LEN+1);
@@ -231,11 +230,11 @@ parser_load_conf(const char *file)
cfg = NULL;
}
+ _parser_y_fini();
return cfg;
}
-static void
-parser_free_kwlist(kw_list_t *list)
+static void parser_free_kwlist(kw_list_t *list)
{
kw_list_t *elt;
@@ -248,8 +247,7 @@ parser_free_kwlist(kw_list_t *list)
}
}
-void
-parser_free_conf(config_parsed_t *cfg)
+void parser_free_conf(config_parsed_t *cfg)
{
section_list_t *sec;
if (cfg)