aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-06-30 00:38:45 +0200
committerPeter Wu <peter@lekensteyn.nl>2015-06-29 22:56:21 +0000
commita36db750e4b9002c91899c7a9b774401f2de1b81 (patch)
treeb987dd16fdb47a17f1a3bd61b1d4d0d3106c712e /plugins
parent305d983442cb8969abcfce0858b5b919bfc4d629 (diff)
plugins/mate: fix some memleaks
Fixes about 5kB leaks in 500+ allocations. There are still some other remaining (and not fixed in this patch because it is hard to track them): - The g_strdup'ed memory via MATE_PARSE for some types (cannot simply g_free after use, it is still needed in some cases). - cfg->transforms and cfg->transport_ranges as used in pdu_decl (mate_grammar.lemon). Tested on a http capture with: tshark -o mate.config:tcp.mate -r ... where tcp.mate is from https://wiki.wireshark.org/Mate/GettingStarted?action=AttachFile&do=get&target=tcp.mate Change-Id: I4c06f948136fc30dfcdb56f7ac8a32a2326ae30d Reviewed-on: https://code.wireshark.org/review/9221 Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mate/mate_parser.l17
-rw-r--r--plugins/mate/mate_runtime.c3
-rw-r--r--plugins/mate/mate_util.c1
3 files changed, 13 insertions, 8 deletions
diff --git a/plugins/mate/mate_parser.l b/plugins/mate/mate_parser.l
index 578a6b4696..45f50c8c63 100644
--- a/plugins/mate/mate_parser.l
+++ b/plugins/mate/mate_parser.l
@@ -86,6 +86,11 @@
#define YY_NO_UNISTD_H
#endif
+static void free_config_frame(mate_config_frame *frame) {
+ g_free(frame->filename);
+ g_free(frame);
+}
+
%}
pdu_kw Pdu
@@ -211,8 +216,7 @@ blk_cmnt_stop "*/"
yy_delete_buffer( YY_CURRENT_BUFFER );
yy_switch_to_buffer( include_stack[include_stack_ptr] );
- g_free(current_frame->filename);
- g_free(current_frame);
+ free_config_frame(current_frame);
current_frame = (mate_config_frame *)g_ptr_array_remove_index(mc->config_stack,mc->config_stack->len-1);
}
}
@@ -318,16 +322,12 @@ extern gboolean mate_load_config(const gchar* filename, mate_config* matecfg) {
yylex();
+ /* Inform parser that end of input has reached. */
MateParser(pParser, 0, NULL,mc);
yyrestart(NULL);
MateParserFree(pParser, g_free );
-
- g_free(current_frame->filename);
- g_free(current_frame);
-
- g_ptr_array_free(mc->config_stack,FALSE);
} CATCH(MateConfigError) {
state = FALSE;
} CATCH_ALL {
@@ -336,6 +336,9 @@ extern gboolean mate_load_config(const gchar* filename, mate_config* matecfg) {
}
ENDTRY;
+ g_ptr_array_foreach(mc->config_stack, (GFunc)free_config_frame, NULL);
+ g_ptr_array_free(mc->config_stack, FALSE);
+
return state;
}
diff --git a/plugins/mate/mate_runtime.c b/plugins/mate/mate_runtime.c
index eede6ede67..2fbd0db5aa 100644
--- a/plugins/mate/mate_runtime.c
+++ b/plugins/mate/mate_runtime.c
@@ -131,7 +131,7 @@ static void destroy_gogs_in_cfg(gpointer k _U_, gpointer v, gpointer p _U_) {
c->last_id = 0;
}
-extern void initialize_mate_runtime(void) {
+void initialize_mate_runtime(void) {
dbg_print (dbg,5,dbg_facility,"initialize_mate: entering");
@@ -826,6 +826,7 @@ static mate_pdu* new_pdu(mate_cfg_pdu* cfg, guint32 framenum, field_info* proto,
apply_transforms(pdu->cfg->transforms,pdu->avpl);
+ g_ptr_array_foreach(data.ranges, (GFunc)g_free, NULL);
g_ptr_array_free(data.ranges,TRUE);
return pdu;
diff --git a/plugins/mate/mate_util.c b/plugins/mate/mate_util.c
index 8378d9b456..bf3f62307d 100644
--- a/plugins/mate/mate_util.c
+++ b/plugins/mate/mate_util.c
@@ -317,6 +317,7 @@ extern AVP* new_avp_from_finfo(const gchar* name, field_info* finfo) {
if (repr) {
value = scs_subscribe(avp_strings, repr);
+ g_free(repr);
#ifdef _AVP_DEBUGGING
dbg_print (dbg_avp,2,dbg_fp,"new_avp_from_finfo: from string: %s",value);
#endif