diff options
author | Dario Lombardo <lomato@gmail.com> | 2017-02-21 16:37:29 +0100 |
---|---|---|
committer | Dario Lombardo <lomato@gmail.com> | 2017-02-24 15:43:32 +0000 |
commit | e1282f28751fefc437280b4cb8b2e1b5df016752 (patch) | |
tree | 0d86c1bd08ad4e55732c05faea7fadecfc567148 | |
parent | 43487d825b9974c0406c940810e1afac371230df (diff) |
dtd: free memory on shutdown.
Change-Id: I502e505730b9310066563bfd9c8df9fceddd0301
Reviewed-on: https://code.wireshark.org/review/20229
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
-rw-r--r-- | epan/dtd.h | 3 | ||||
-rw-r--r-- | epan/dtd_preparse.l | 15 | ||||
-rw-r--r-- | epan/epan.c | 2 |
3 files changed, 13 insertions, 7 deletions
diff --git a/epan/dtd.h b/epan/dtd.h index d2efae9b7a..64e07e591c 100644 --- a/epan/dtd.h +++ b/epan/dtd.h @@ -54,7 +54,10 @@ typedef struct _dtd_named_list_t { GPtrArray* list; } dtd_named_list_t; +typedef struct _dtd_preparse_scanner_state Dtd_PreParse_scanner_state_t; + extern GString* dtd_preparse(const gchar* dname, const gchar* fname, GString* err); extern dtd_build_data_t* dtd_parse(GString* s); +extern const gchar* dtd_location(Dtd_PreParse_scanner_state_t* state); #endif diff --git a/epan/dtd_preparse.l b/epan/dtd_preparse.l index e3d0c6d9a3..9a4137736b 100644 --- a/epan/dtd_preparse.l +++ b/epan/dtd_preparse.l @@ -99,7 +99,7 @@ #define ECHO g_string_append(yyextra->current,yytext); -typedef struct { +typedef struct _dtd_preparse_scanner_state { const gchar* dtd_dirname; const gchar* filename; guint linenum; @@ -113,7 +113,6 @@ typedef struct { } Dtd_PreParse_scanner_state_t; static const gchar* replace_entity(Dtd_PreParse_scanner_state_t* state, gchar* s); -static const gchar* location(Dtd_PreParse_scanner_state_t* state); #define YY_USER_INIT { \ BEGIN OUTSIDE; \ @@ -176,7 +175,7 @@ newline \n %% -{entity} if (yyextra->current) g_string_append_printf(yyextra->current,"%s\n%s\n",replace_entity(yyextra, yytext),location(yyextra)); +{entity} if (yyextra->current) g_string_append_printf(yyextra->current,"%s\n%s\n",replace_entity(yyextra, yytext),dtd_location(yyextra)); {whitespace} if (yyextra->current) g_string_append(yyextra->current," "); @@ -192,13 +191,13 @@ newline \n {newline} { yyextra->linenum++; - if (yyextra->current) g_string_append_printf(yyextra->current,"%s\n",location(yyextra)); + if (yyextra->current) g_string_append_printf(yyextra->current,"%s\n",dtd_location(yyextra)); } <OUTSIDE>{entity_start} { BEGIN IN_ENTITY; } <IN_ENTITY>{name} { yyextra->entity_name = g_strdup_printf("%%%s;",yytext); BEGIN NAMED_ENTITY; } -<NAMED_ENTITY>{quote} { yyextra->current = g_string_new(location(yyextra)); BEGIN IN_QUOTE; } +<NAMED_ENTITY>{quote} { yyextra->current = g_string_new(dtd_location(yyextra)); BEGIN IN_QUOTE; } <IN_QUOTE>{quote} { g_hash_table_insert(yyextra->entities,yyextra->entity_name,yyextra->current); BEGIN ENTITY_DONE; } <IN_QUOTE>{percent} | <IN_QUOTE>{non_quote} | @@ -227,11 +226,13 @@ static const gchar* replace_entity(Dtd_PreParse_scanner_state_t* state, gchar* e } -static const gchar* location(Dtd_PreParse_scanner_state_t* state) { +const gchar* dtd_location(Dtd_PreParse_scanner_state_t* state) { static gchar* loc = NULL; if (loc) g_free(loc); + if (!state) return NULL; + loc = g_strdup_printf("<? wireshark:location %s:%u ?>", state->filename, state->linenum); return loc; @@ -275,7 +276,7 @@ extern GString* dtd_preparse(const gchar* dname,const gchar* fname, GString* er state.error = err; state.entities = g_hash_table_new(g_str_hash,g_str_equal); - state.current = state.output = g_string_new(location(&state)); + state.current = state.output = g_string_new(dtd_location(&state)); state.entity_name = NULL; /* Associate the state with the scanner */ diff --git a/epan/epan.c b/epan/epan.c index e5f2bf4867..ff65ebf86b 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -65,6 +65,7 @@ #include "reassemble.h" #include "srt_table.h" #include "stats_tree.h" +#include <dtd.h> #ifdef HAVE_LUA #include <lua.h> @@ -225,6 +226,7 @@ epan_cleanup(void) export_pdu_cleanup(); disabled_protos_cleanup(); stats_tree_cleanup(); + dtd_location(NULL); #ifdef HAVE_LUA wslua_cleanup(); #endif |