aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-05-09 22:28:57 +0200
committerPeter Wu <peter@lekensteyn.nl>2018-05-14 13:42:10 +0000
commitbb81e1807b2a5b67905cfa1594dbbb535fe8b37e (patch)
treee4f934c0210d35b7563f790bd7a7e08fa5de377c
parentd80acae40d14efeb857258ca923637b590dd6be9 (diff)
Free g_ptr_array_free-related memory leaks
g_ptr_array_free(a, FALSE) returns "a->pdata". Callers that do not handle this will leak memory (e.g. "tshark -G plugins"). Convert other users to use the return value instead of direct access to "a->pdata". Change-Id: I29835477d587f5f54bf0d94cdae9f375e3da3ce3 Reviewed-on: https://code.wireshark.org/review/27437 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
-rw-r--r--epan/dfilter/dfilter-macro.c3
-rw-r--r--epan/expert.c2
-rw-r--r--epan/proto.c4
-rw-r--r--epan/wslua/wslua_listener.c2
-rw-r--r--plugins/epan/mate/mate_grammar.lemon2
-rw-r--r--plugins/epan/mate/mate_parser.l2
-rw-r--r--plugins/epan/mate/mate_runtime.c2
-rw-r--r--ui/qt/funnel_string_dialog.cpp5
-rw-r--r--wsutil/plugins.c2
9 files changed, 11 insertions, 13 deletions
diff --git a/epan/dfilter/dfilter-macro.c b/epan/dfilter/dfilter-macro.c
index 2ad7f5d366..f94970a895 100644
--- a/epan/dfilter/dfilter-macro.c
+++ b/epan/dfilter/dfilter-macro.c
@@ -409,12 +409,11 @@ done:
g_ptr_array_add(parts,NULL);
g_free(m->parts);
- m->parts = (gchar**)parts->pdata;
+ m->parts = (gchar **)g_ptr_array_free(parts, FALSE);
g_free(m->args_pos);
m->args_pos = (int*)(void *)args_pos->data;
- g_ptr_array_free(parts,FALSE);
g_array_free(args_pos,FALSE);
m->argc = argc;
diff --git a/epan/expert.c b/epan/expert.c
index 30c079b4d3..5538f2a433 100644
--- a/epan/expert.c
+++ b/epan/expert.c
@@ -288,7 +288,7 @@ expert_cleanup(void)
}
if (deregistered_expertinfos) {
- g_ptr_array_free(deregistered_expertinfos, FALSE);
+ g_ptr_array_free(deregistered_expertinfos, TRUE);
deregistered_expertinfos = NULL;
}
}
diff --git a/epan/proto.c b/epan/proto.c
index 2e4f11e252..0d378c7706 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -586,12 +586,12 @@ proto_cleanup_base(void)
}
if (deregistered_fields) {
- g_ptr_array_free(deregistered_fields, FALSE);
+ g_ptr_array_free(deregistered_fields, TRUE);
deregistered_fields = NULL;
}
if (deregistered_data) {
- g_ptr_array_free(deregistered_data, FALSE);
+ g_ptr_array_free(deregistered_data, TRUE);
deregistered_data = NULL;
}
diff --git a/epan/wslua/wslua_listener.c b/epan/wslua/wslua_listener.c
index 3c60645937..4a449ed64e 100644
--- a/epan/wslua/wslua_listener.c
+++ b/epan/wslua/wslua_listener.c
@@ -386,7 +386,7 @@ static void deregister_tap_listener (gpointer data, gpointer userdata) {
int wslua_deregister_listeners(lua_State* L) {
g_ptr_array_foreach(listeners, deregister_tap_listener, L);
- g_ptr_array_free(listeners, FALSE);
+ g_ptr_array_free(listeners, TRUE);
listeners = NULL;
return 0;
diff --git a/plugins/epan/mate/mate_grammar.lemon b/plugins/epan/mate/mate_grammar.lemon
index c041d93ffb..ba020c13d6 100644
--- a/plugins/epan/mate/mate_grammar.lemon
+++ b/plugins/epan/mate/mate_grammar.lemon
@@ -436,7 +436,7 @@ pdu_decl ::=
g_ptr_array_add(transport_stack,g_ptr_array_remove_index(Stack,i));
}
- g_ptr_array_free(Stack,FALSE);
+ g_ptr_array_free(Stack, TRUE);
cfg->transport_ranges = transport_stack;
cfg->payload_ranges = Payload;
diff --git a/plugins/epan/mate/mate_parser.l b/plugins/epan/mate/mate_parser.l
index 2b61c9d069..0c140f2cb8 100644
--- a/plugins/epan/mate/mate_parser.l
+++ b/plugins/epan/mate/mate_parser.l
@@ -403,7 +403,7 @@ extern gboolean mate_load_config(const gchar* filename, mate_config* mc) {
fclose(in);
g_ptr_array_foreach(mc->config_stack, ptr_array_free, NULL);
- g_ptr_array_free(mc->config_stack, FALSE);
+ g_ptr_array_free(mc->config_stack, TRUE);
return status;
}
diff --git a/plugins/epan/mate/mate_runtime.c b/plugins/epan/mate/mate_runtime.c
index 293f4ce6f7..2bb31eb941 100644
--- a/plugins/epan/mate/mate_runtime.c
+++ b/plugins/epan/mate/mate_runtime.c
@@ -78,7 +78,7 @@ static gboolean destroy_mate_gogs(gpointer k _U_, gpointer v, gpointer p _U_) {
if (gog->gog_keys) {
gog_remove_keys(gog);
- g_ptr_array_free(gog->gog_keys,FALSE);
+ g_ptr_array_free(gog->gog_keys, TRUE);
}
g_slice_free(mate_max_size,(mate_max_size*)gog);
diff --git a/ui/qt/funnel_string_dialog.cpp b/ui/qt/funnel_string_dialog.cpp
index cd316fae30..affc5e8bca 100644
--- a/ui/qt/funnel_string_dialog.cpp
+++ b/ui/qt/funnel_string_dialog.cpp
@@ -74,9 +74,8 @@ void FunnelStringDialog::on_buttonBox_accepted()
}
g_ptr_array_add(returns, NULL);
- dialog_cb_((gchar**)returns->pdata, dialog_cb_data_);
-
- g_ptr_array_free(returns, FALSE);
+ gchar **user_input = (gchar **)g_ptr_array_free(returns, FALSE);
+ dialog_cb_(user_input, dialog_cb_data_);
}
void FunnelStringDialog::stringDialogNew(const QString title, const QStringList field_name_list, funnel_dlg_cb_t dialog_cb, void *dialog_cb_data)
diff --git a/wsutil/plugins.c b/wsutil/plugins.c
index 649fad4bf7..debaa3a6dd 100644
--- a/wsutil/plugins.c
+++ b/wsutil/plugins.c
@@ -244,7 +244,7 @@ plugins_get_descriptions(plugin_description_callback callback, void *callback_da
callback(plug->name, plug->version, plug->type_name, g_module_name(plug->handle), callback_data);
}
- g_ptr_array_free(plugins_array, FALSE);
+ g_ptr_array_free(plugins_array, TRUE);
}
static void