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>
This commit is contained in:
parent
305d983442
commit
a36db750e4
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue