summaryrefslogtreecommitdiff
path: root/ui/gtk/prefs_capture.c
diff options
context:
space:
mode:
authorMikael Kanstrup <mikael.kanstrup@gmail.com>2015-11-23 16:33:41 +0100
committerPeter Wu <peter@lekensteyn.nl>2015-11-25 12:03:33 +0000
commit9107fb6039260ad2e84f303fd824dc66e62bdd24 (patch)
tree154d740bde2484a932109d5eb7fdb7a74f80e55a /ui/gtk/prefs_capture.c
parent571ed4d25907dae80bd9c0e3e5822fe473d77d2d (diff)
downloadwireshark-9107fb6039260ad2e84f303fd824dc66e62bdd24.tar.gz
Fix memory leaks related to hide_interface function
Valgrind report leaks like these: 6 bytes in 6 blocks are definitely lost in loss record 2,197 of 46,703 at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0xA5C1610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0xA5D8B0E: g_strdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0x69A211: ManageInterfacesDialog::localAccepted() (manage_interfaces_dialog.cpp:454) by 0x69A500: ManageInterfacesDialog::on_buttonBox_accepted() (manage_interfaces_dialog.cpp:211) by 0x71DB32: ManageInterfacesDialog::qt_metacall(QMetaObject::Call, int, void**) (manage_interfaces_dialog.moc.cpp:245) by 0xBEBE36C: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1) by 0xBEBE2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1) by 0xAF87E41: QAbstractButton::clicked(bool) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.2.1) by 0xAD11095: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.2.1) by 0xAD11BAD: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.2.1) by 0xAD11D23: QAbstractButton::mouseReleaseEvent(QMouseEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.2.1) 96 bytes in 4 blocks are definitely lost in loss record 42,458 of 52,779 at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0xA5C1610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0xA5D722D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0xA5B84F3: g_list_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0x731F9A: hide_interface (iface_lists.c:426) by 0x69A211: ManageInterfacesDialog::localAccepted() (manage_interfaces_dialog.cpp:454) by 0x69A4F0: ManageInterfacesDialog::on_buttonBox_accepted() (manage_interfaces_dialog.cpp:211) by 0x71DB22: ManageInterfacesDialog::qt_metacall(QMetaObject::Call, int, void**) (manage_interfaces_dialog.moc.cpp:245) by 0xBEBE36C: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1) by 0xBEBE2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1) by 0xAF87E41: QAbstractButton::clicked(bool) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.2.1) by 0xAD11095: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.2.1) These are caused by leaks inside hide_interface function and among its users. Fixed by letting hide_interface function free its resources properly and making sure the users follow the pattern. Change-Id: I91527b83d36dc38b402d0f4a1db4b7db40fd83f9 Reviewed-on: https://code.wireshark.org/review/12113 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'ui/gtk/prefs_capture.c')
-rw-r--r--ui/gtk/prefs_capture.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/ui/gtk/prefs_capture.c b/ui/gtk/prefs_capture.c
index b95e05c4bf..5bd5ee4e6c 100644
--- a/ui/gtk/prefs_capture.c
+++ b/ui/gtk/prefs_capture.c
@@ -2164,13 +2164,12 @@ ifopts_write_new_hide(void)
gboolean hide;
gchar *new_hide;
- /* new preferences "hidden" interfaces string */
- new_hide = (gchar *)g_malloc0(MAX_VAL_LEN);
-
/* get "hide" flag text for each row (interface) */
model = gtk_tree_view_get_model(GTK_TREE_VIEW(cur_list));
store = GTK_LIST_STORE(model);
if( gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter) ) {
+ /* new preferences "hidden" interfaces string */
+ new_hide = (gchar *)g_malloc0(MAX_VAL_LEN);
while (more_items) {
gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
DEVICE_COLUMN, &ifnm,